<menu>
...
<group
android:id="@+id/nav_group_footer"
android:checkableBehavior="none">
<item
android:id="@+id/nav_item_last_updated"
android:title="Last updated: 2018-09-07 21:47" />
</group>
</menu>
我可以在像mLastUpdatedView = mNavigationView.getMenu().findItem(R.id.nav_item_last_updated);
这样的代码中处理它,但后来我不确定如何编辑它的样式。我一直在搜索并看到一些可能的解决方案涉及到更改styles.xml但我认为如果我更改其他菜单项也将更改。我只想从页脚中删除粗体textstyle。有没有办法以编程方式执行此操作?
follow this way for achieving that:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main2"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main2"
app:menu="@menu/activity_main2_drawer" >
<TextView
android:layout_gravity="bottom"
android:text="Last updated: 2018-09-07 21:47"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>.