如何只更改secondaryText的字体大小?

时间:2017-02-28 04:39:28

标签: android navigation-drawer

我想更改菜单标题字体大小,因此我在自定义主题NavigationView中定义了属性,但它也更改了headerLayout文本的字体大小。如何仅更改菜单标题的字体大小?我是初学者!

enter image description here

activity_main.xml中

<?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="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:layout_marginLeft="-64dp"
        android:fitsSystemWindows="true"
        android:theme="@style/NavigationView"
        app:itemTextAppearance="@style/ItemFont"
        app:itemTextColor="@color/state_color"
        app:itemIconTint="@color/colorAccent"
        app:headerLayout="@layout/nav_header_main2"
        app:menu="@menu/activity_main2_drawer"
        >
        <include layout="@layout/nav_header_main2"/>
        </android.support.design.widget.NavigationView>

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

styles.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:itemBackground">@color/state_color</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="actionMenuTextColor">@color/white</item>
</style>
<!--Navigation Title font-->
<style name="NavigationView">
    <item name="android:textSize">10.5pt</item>
    <item name="android:textColorSecondary">@color/colorPrimary</item>
</style>
<!--Item font-->
<style name="ItemFont">
    <item name="android:textSize">7.5pt</item>
</style>

1 个答案:

答案 0 :(得分:0)

替换以下行

机器人:主题=&#34; @风格/ NavigationView&#34;

  

应用程式:主题=&#34; @风格/ NavigationView&#34;