0

I know that there are many questions about it( and many answer, but I've created a new project with Navigation Drawer activity in android studio, And I can't see where change the properties of the menu.I want to change font size, color of icon, size of icon, etcetera and I just see this:

enter image description here

<

<group android:checkableBehavior="single"


    >
    <item
        android:id="@+id/crea"
        android:icon="@drawable/ic_idea"
        android:title="Arnold" />
    <item
        android:id="@+id/descubrir"
        android:icon="@android:drawable/ic_menu_search"
        android:title="Worty" />
    <item
        android:id="@+id/popular"
        android:icon="@drawable/ic_action_name"
        android:title="Basea" />
    <item
        android:id="@+id/vende"
        android:icon="@android:drawable/ic_menu_compass"
        android:title="Doroty" />
</group>

<item android:title="comunicate">
    <menu>
        <item
            android:id="@+id/nav_share"
            android:icon="@android:drawable/ic_menu_share"
            android:title="Amigos" />
        <item
            android:id="@+id/nav_send"
            android:icon="@android:drawable/ic_menu_send"
            android:title="Registrate" />
    </menu>
</item>

I really need help, I only have 3 months in java and android. This is my activity code:

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);


}

@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}


    return super.onOptionsItemSelected(item);
}

@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();



    if (id == R.id.crea) {

        // Handle the camera action
    } else if (id == R.id.descubrir) {

    } else if (id == R.id.popular) {

    } else if (id == R.id.vende) {

    } else if (id == R.id.nav_share) {

    } else if (id == R.id.nav_send) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);

    return true;

1 Answers1

0

I was looking for the same thing. I got it done by doing the following:

After creating the object from the NavigationView class insert the following code, which will multiply the font size by 50% than it was before.

for(int i = 0; i < navigationView.getMenu().size(); i++) {
        MenuItem item = navigationView.getMenu().getItem(i);
        SpannableString spanString = new SpannableString(navigationView.getMenu().getItem(i).getTitle().toString());
        int end = spanString.length();
        spanString.setSpan(new RelativeSizeSpan(1.5f), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        item.setTitle(spanString);
    }

and that's it, your good to go!

Ahmed Awad
  • 1,787
  • 3
  • 16
  • 22