Set a specific color for a specific item in the navigation drawer [duplicate]
This question already has an answer here:
Change background color of single specific menu items of navigationView
4 answers
Currently i want to set a specific color for one of my item in the navigation drawer:
here is my code:
Menu menuNav= mNavigationView.getMenu();
MenuItem nav_item2 = menuNav.findItem(R.id.drawer_pay).setIconTintList(ContextCompat.getColorStateList(
mNavigationView.getContext(),
R.color.background_gray));
but im receiving this kind of error:
java.lang.NoSuchMethodError: No interface method setIconTintList(Landroid/content/res/ColorStateList;)Landroid/view/MenuItem; in class Landroid/view/MenuItem; or its super classes (declaration of 'android.view.MenuItem' appears in /system/framework/framework.jar:classes2.dex)
android navigation-drawer
marked as duplicate by Nilesh Rathod
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 '18 at 8:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Change background color of single specific menu items of navigationView
4 answers
Currently i want to set a specific color for one of my item in the navigation drawer:
here is my code:
Menu menuNav= mNavigationView.getMenu();
MenuItem nav_item2 = menuNav.findItem(R.id.drawer_pay).setIconTintList(ContextCompat.getColorStateList(
mNavigationView.getContext(),
R.color.background_gray));
but im receiving this kind of error:
java.lang.NoSuchMethodError: No interface method setIconTintList(Landroid/content/res/ColorStateList;)Landroid/view/MenuItem; in class Landroid/view/MenuItem; or its super classes (declaration of 'android.view.MenuItem' appears in /system/framework/framework.jar:classes2.dex)
android navigation-drawer
marked as duplicate by Nilesh Rathod
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 '18 at 8:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Change background color of single specific menu items of navigationView
4 answers
Currently i want to set a specific color for one of my item in the navigation drawer:
here is my code:
Menu menuNav= mNavigationView.getMenu();
MenuItem nav_item2 = menuNav.findItem(R.id.drawer_pay).setIconTintList(ContextCompat.getColorStateList(
mNavigationView.getContext(),
R.color.background_gray));
but im receiving this kind of error:
java.lang.NoSuchMethodError: No interface method setIconTintList(Landroid/content/res/ColorStateList;)Landroid/view/MenuItem; in class Landroid/view/MenuItem; or its super classes (declaration of 'android.view.MenuItem' appears in /system/framework/framework.jar:classes2.dex)
android navigation-drawer
This question already has an answer here:
Change background color of single specific menu items of navigationView
4 answers
Currently i want to set a specific color for one of my item in the navigation drawer:
here is my code:
Menu menuNav= mNavigationView.getMenu();
MenuItem nav_item2 = menuNav.findItem(R.id.drawer_pay).setIconTintList(ContextCompat.getColorStateList(
mNavigationView.getContext(),
R.color.background_gray));
but im receiving this kind of error:
java.lang.NoSuchMethodError: No interface method setIconTintList(Landroid/content/res/ColorStateList;)Landroid/view/MenuItem; in class Landroid/view/MenuItem; or its super classes (declaration of 'android.view.MenuItem' appears in /system/framework/framework.jar:classes2.dex)
This question already has an answer here:
Change background color of single specific menu items of navigationView
4 answers
android navigation-drawer
android navigation-drawer
asked Nov 15 '18 at 8:13
netflix spotifynetflix spotify
587
587
marked as duplicate by Nilesh Rathod
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 '18 at 8:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Nilesh Rathod
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 '18 at 8:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
First Way
try using:
app:itemIconTint="@color/color_pink" //selected icon color
app:itemTextColor="@color/color_pink" //selected text color
app:itemBackground="@color/color_gray"
For your NavigationView
<android.support.design.widget.NavigationView
android:id="@+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header_layout"
app:itemIconTint="@color/color_pink"
app:itemTextColor="@color/color_pink"
app:itemBackground="@color/color_gray"
app:menu="@menu/menu_drawer" />
Second Way
For programetically change use:
navigationView.setItemTextColor(ColorStateList1);
navigationView.setItemIconTintList(ColorStateList2);
Define ColorStateList1
and ColorStateList2
as:
For Navigation View Item 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList1 = new ColorStateList(state, color);
For Navigation View Item Icon 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList2 = new ColorStateList(states, colors);
This will change the color of all item in the navigation drawer, i need to be specific.
– netflix spotify
Nov 15 '18 at 9:13
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First Way
try using:
app:itemIconTint="@color/color_pink" //selected icon color
app:itemTextColor="@color/color_pink" //selected text color
app:itemBackground="@color/color_gray"
For your NavigationView
<android.support.design.widget.NavigationView
android:id="@+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header_layout"
app:itemIconTint="@color/color_pink"
app:itemTextColor="@color/color_pink"
app:itemBackground="@color/color_gray"
app:menu="@menu/menu_drawer" />
Second Way
For programetically change use:
navigationView.setItemTextColor(ColorStateList1);
navigationView.setItemIconTintList(ColorStateList2);
Define ColorStateList1
and ColorStateList2
as:
For Navigation View Item 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList1 = new ColorStateList(state, color);
For Navigation View Item Icon 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList2 = new ColorStateList(states, colors);
This will change the color of all item in the navigation drawer, i need to be specific.
– netflix spotify
Nov 15 '18 at 9:13
add a comment |
First Way
try using:
app:itemIconTint="@color/color_pink" //selected icon color
app:itemTextColor="@color/color_pink" //selected text color
app:itemBackground="@color/color_gray"
For your NavigationView
<android.support.design.widget.NavigationView
android:id="@+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header_layout"
app:itemIconTint="@color/color_pink"
app:itemTextColor="@color/color_pink"
app:itemBackground="@color/color_gray"
app:menu="@menu/menu_drawer" />
Second Way
For programetically change use:
navigationView.setItemTextColor(ColorStateList1);
navigationView.setItemIconTintList(ColorStateList2);
Define ColorStateList1
and ColorStateList2
as:
For Navigation View Item 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList1 = new ColorStateList(state, color);
For Navigation View Item Icon 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList2 = new ColorStateList(states, colors);
This will change the color of all item in the navigation drawer, i need to be specific.
– netflix spotify
Nov 15 '18 at 9:13
add a comment |
First Way
try using:
app:itemIconTint="@color/color_pink" //selected icon color
app:itemTextColor="@color/color_pink" //selected text color
app:itemBackground="@color/color_gray"
For your NavigationView
<android.support.design.widget.NavigationView
android:id="@+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header_layout"
app:itemIconTint="@color/color_pink"
app:itemTextColor="@color/color_pink"
app:itemBackground="@color/color_gray"
app:menu="@menu/menu_drawer" />
Second Way
For programetically change use:
navigationView.setItemTextColor(ColorStateList1);
navigationView.setItemIconTintList(ColorStateList2);
Define ColorStateList1
and ColorStateList2
as:
For Navigation View Item 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList1 = new ColorStateList(state, color);
For Navigation View Item Icon 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList2 = new ColorStateList(states, colors);
First Way
try using:
app:itemIconTint="@color/color_pink" //selected icon color
app:itemTextColor="@color/color_pink" //selected text color
app:itemBackground="@color/color_gray"
For your NavigationView
<android.support.design.widget.NavigationView
android:id="@+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header_layout"
app:itemIconTint="@color/color_pink"
app:itemTextColor="@color/color_pink"
app:itemBackground="@color/color_gray"
app:menu="@menu/menu_drawer" />
Second Way
For programetically change use:
navigationView.setItemTextColor(ColorStateList1);
navigationView.setItemIconTintList(ColorStateList2);
Define ColorStateList1
and ColorStateList2
as:
For Navigation View Item 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList1 = new ColorStateList(state, color);
For Navigation View Item Icon 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.BLUE,
Color.WHITE,
Color.WHITE
};
ColorStateList ColorStateList2 = new ColorStateList(states, colors);
answered Nov 15 '18 at 8:30
Utkarsh SrivastavaUtkarsh Srivastava
130111
130111
This will change the color of all item in the navigation drawer, i need to be specific.
– netflix spotify
Nov 15 '18 at 9:13
add a comment |
This will change the color of all item in the navigation drawer, i need to be specific.
– netflix spotify
Nov 15 '18 at 9:13
This will change the color of all item in the navigation drawer, i need to be specific.
– netflix spotify
Nov 15 '18 at 9:13
This will change the color of all item in the navigation drawer, i need to be specific.
– netflix spotify
Nov 15 '18 at 9:13
add a comment |