![](/img/trans.png)
[英]How do I change Item title font color for an Item that contains a menu in Navigation Drawer
[英]How do i change Drawer item parents Text color?
在styles.xml
為您的navigationDrawer
頭創建樣式
<style name="HeaderTextAppreance">
<item name="android:textColor">@color/colorPrimary</item>
</style>
然后在您的活動中使用ID來訪問navigation header
,然后嘗試以下操作:
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
Menu menu = navigationView.getMenu();
MenuItem tools= menu.findItem(R.id.yourId);
SpannableString s = new SpannableString(tools.getTitle());
s.setSpan(new TextAppearanceSpan(this, R.style.HeaderTextAppreance), 0, s.length(), 0);
tools.setTitle(s);
navigationView.setNavigationItemSelectedListener(this);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.