【问题标题】:Is it possible to remove bold styling from menu item in NavigationView?是否可以从 NavigationView 的菜单项中删除粗体样式?
【发布时间】:2019-02-12 10:01:27
【问题描述】:

<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 的解决方案,但我认为如果我在那里更改内容,其他菜单项也会更改。我只想从页脚中删除粗体文本样式。有没有办法以编程方式做到这一点?

【问题讨论】:

标签: android android-menu navigation-drawer android-navigationview


【解决方案1】:
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>.

【讨论】:

    猜你喜欢
    • 2010-10-02
    • 2020-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-03
    • 2021-04-07
    相关资源
    最近更新 更多