本文整理匯總了Java中android.support.design.widget.NavigationView.setItemTextColor方法的典型用法代碼示例。如果您正苦於以下問題:Java NavigationView.setItemTextColor方法的具體用法?Java NavigationView.setItemTextColor怎麽用?Java NavigationView.setItemTextColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.design.widget.NavigationView
的用法示例。
在下文中一共展示了NavigationView.setItemTextColor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: process
import android.support.design.widget.NavigationView; //導入方法依賴的package包/類
@Override
public void process(@NonNull Context context, @Nullable String key, @Nullable NavigationView view, @Nullable Void extra) {
if (view == null || !Config.navigationViewThemed(context, key))
return;
boolean darkTheme = false;
if (view.getBackground() != null && view.getBackground() instanceof ColorDrawable) {
final ColorDrawable cd = (ColorDrawable) view.getBackground();
darkTheme = !ATEUtil.isColorLight(cd.getColor());
}
final ColorStateList iconSl = new ColorStateList(
new int[][]{
new int[]{-android.R.attr.state_checked},
new int[]{android.R.attr.state_checked}
},
new int[]{
Config.navigationViewNormalIcon(context, key, darkTheme),
Config.navigationViewSelectedIcon(context, key, darkTheme)
});
final ColorStateList textSl = new ColorStateList(
new int[][]{
new int[]{-android.R.attr.state_checked},
new int[]{android.R.attr.state_checked}
},
new int[]{
Config.navigationViewNormalText(context, key, darkTheme),
Config.navigationViewSelectedText(context, key, darkTheme)
});
view.setItemTextColor(textSl);
view.setItemIconTintList(iconSl);
StateListDrawable bgDrawable = new StateListDrawable();
bgDrawable.addState(new int[]{android.R.attr.state_checked}, new ColorDrawable(
Config.navigationViewSelectedBg(context, key, darkTheme)));
view.setItemBackground(bgDrawable);
// TODO not needed since the layout inflater will catch it?
// final View headerView = view.getHeaderView(0);
// if (headerView != null) ATE.themeView(context, headerView, key);
}