AykutBurock
AykutBurock

Reputation: 53

How can change textsize of menu item?

My project include navigation drawer in menu folder of the values named drawer.xml. Items of this menu has icon and title. The font size of items are normal for all screens. But, I must increase font size and I should change icon size for sw600dp layout.

I tried solution that I found from stackOverflow. I added the code below to style.xml in values-sw600dpand I increased icon size in drawable-sw600dp. But that all didn't work. <style name="NavDrawerTextStyle" parent="Base.TextAppearance.AppCompat"> <item name="android:textSize">50sp</item> </style>

drawer.xml

      <?xml version="1.0" encoding="utf-8"?>
      <menu 
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto">
      <group

      android:id="@+id/group_member"
      android:checkableBehavior="single">
      <item
        android:id="@+id/navigation_sign_in"
        android:icon="@drawable/ic_account"
        app:theme="@style/NavDrawerTextStyle"
        android:title="@string/menu_user_settings" />
      </group>
      <group
      android:id="@+id/group_information"
      android:checkableBehavior="single">
      <item
        android:id="@+id/navigation_registered_users_list"
        android:icon="@drawable/ic_people_black_24dp"
        android:title="@string/menu_registered_user_list" />
      <item
        android:icon="@drawable/ic_star_black_24dp"
        android:title="@string/menu_rate_us" />
    <item
        android:icon="@drawable/ic_info_outline_black_24dp"
        android:title="@string/menu_about_us" />
    <item
        android:icon="@drawable/ic_phone_in_talk_black_24dp"
        android:title="@string/menu_contact" />
</group>

Upvotes: 2

Views: 1229

Answers (1)

Nigam Patro
Nigam Patro

Reputation: 2770

Instead of setting the theme for every element, set the theme to your Navigationview. Like,

<style name="NavDrawerTextStyle">
        <item name="android:textSize">50sp</item>
</style>

to Navigationview

<android.support.design.widget.NavigationView
    ...
    android:theme="@style/NavDrawerTextStyle"
     />

Upvotes: 3

Related Questions