Answers for "how to add options menu items into cardview android"

0

change activity main drawer items text color android

<android.support.design.widget.NavigationView
    app:menu="@menu/drawer_view" <!-- add this line for items' text color -->
    app:itemTextColor="@color/colorWhite"> <!-- add this line for items' icons color -->
Posted by: Guest on March-14-2020
0

change activity main drawer items text color programmatically android

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

	//items text color
    int[][] state = new int[][] {
            new int[] {-android.R.attr.state_enabled}, // disabled
            new int[] {android.R.attr.state_enabled}, // enabled
            new int[] {-android.R.attr.state_checked}, // unchecked
            new int[] { android.R.attr.state_pressed}  // pressed

    };

    int[] color = new int[] {
            Color.WHITE,
            Color.WHITE,
            Color.WHITE,
            Color.WHITE
    };

    ColorStateList colorStateList1 = new ColorStateList(state, color);


    //icons color
    int[][] states = new int[][] {
            new int[] {-android.R.attr.state_enabled}, // disabled
            new int[] {android.R.attr.state_enabled}, // enabled
            new int[] {-android.R.attr.state_checked}, // unchecked
            new int[] { android.R.attr.state_pressed}  // pressed

    };

    int[] colors = new int[] {
            Color.WHITE,
            Color.WHITE,
            Color.WHITE,
            Color.WHITE
    };
    ColorStateList colorStateList2 = new ColorStateList(states, colors);
    navigationView.setItemTextColor(colorStateList1);
    navigationView.setItemIconTintList(colorStateList2);
Posted by: Guest on March-14-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language