【问题标题】:Setting itemTextAppearance for Android NavigationView gives a "bold" text style为 Android NavigationView 设置 itemTextAppearance 会提供“粗体”文本样式
【发布时间】:2018-09-07 22:37:41
【问题描述】:

我在我的设计师和我的 Android 应用程序之间定义了 4 种文本样式。

我今天必须添加一个导航抽屉,并为导航抽屉菜单项提供我们已经设置的样式。问题是,当我添加样式时,它显示的文本看起来像是粗体。有人看到我的代码有任何问题吗?

<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/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"

            android:layout_width="match_parent"
            android:layout_height="?android:attr/actionBarSize"
            android:background="?colorPrimary"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            />

        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />
    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/offWhite"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/custom_nav_header"
        app:itemBackground="@drawable/nav_drawer_menu_item_selector"
        app:itemTextColor="@color/color_drawer"
        app:itemTextAppearance="@style/Header4" <!--The issue -->
        app:menu="@menu/activity_drawer" />

</android.support.v4.widget.DrawerLayout>

这是 Header4 的定义

<style name="Header4">
    <item name="android:textSize">16sp</item>
    <item name="android:letterSpacing">.06</item>
</style>

【问题讨论】:

  • 这是仅在预览版上,还是在设备或模拟器上运行时也在应用中?

标签: android android-design-library android-support-design


【解决方案1】:

我不确定可能是什么问题,但请尝试更改字体或将文本样式设置为“正常”。

【讨论】:

    【解决方案2】:

    试试:

    在你的 dimen.xml 你可以放:

    <dimen name="design_bottom_navigation_text_size" tools:override="true">16sp</dimen>
    <dimen name="design_bottom_navigation_active_text_size" tools:override="true">16sp</dimen>
    

    【讨论】:

      猜你喜欢
      • 2015-09-23
      • 2014-03-07
      • 1970-01-01
      • 1970-01-01
      • 2015-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-26
      相关资源
      最近更新 更多