我正在尝试更改导航抽屉项目的字体,但无法正常工作。 我将其设置为特定的主题/样式,即“材料设计按钮”文本。我已经可以在工具栏(动作栏)上使用它了,但是我似乎根本无法更改导航抽屉中项目的文本。
我正在尝试设置以下内容:NavDrawer
转换为该字体/样式:工具栏样式
。
我尝试在NavigationView中更改“ 应用”属性,但对我来说不起作用。这是我的layout.xml和styles.xml。
欢迎任何帮助或建议,谢谢!
Layout.xml :
<android.support.design.widget.CoordinatorLayout>
<LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/fragment_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light"
app:titleTextAppearance="@style/TextAppearance.AppTheme.Toolbar">
</android.support.v7.widget.Toolbar>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
style="@style/Widget.MaterialComponents.NavigationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/themePrimaryLight"
app:elevation="8dp"
app:headerLayout="@layout/nav_header"
app:itemIconPadding="60dp"
app:itemIconTint="@color/colorSecondLight"
app:itemTextAppearance="@font/rubik_regular"
app:itemTextColor="@color/colorSecondLight"
app:menu="@menu/nav_drawer_base" />
</android.support.v4.widget.DrawerLayout>
Styles.xml :
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorSecondDark</item>
<item name="android:statusBarColor">@color/fullAlpha</item>
</style>
<style name="AppThemeActionBar" parent="Theme.MaterialComponents.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorSecondDark</item>
</style>
<style name="Widget.AppTheme.Toolbar" parent="Widget.AppCompat.Toolbar">
<item name="titleTextAppearance">@style/TextAppearance.AppTheme.Toolbar</item>
</style>
<style name="TextAppearance.AppTheme.Toolbar" parent="TextAppearance.MaterialComponents.Button">
<item name="android:textSize">16sp</item>
</style>
<style name="NavigationDrawerStyle">
<item name="android:textSize">14sp</item>
<item name="android:itemTextAppearance">@style/TextAppearance.AppTheme.Toolbar</item>
</style>
</resources>