我试图显示一个图标旁边的项目在我的菜单中的导航抽屉,但由于某些原因,图标总是出现在灰色而不是原来的颜色(棕色)。有没有什么办法可以防止这种情况的发生,以显示图标的原始颜色?
MainActivity.java
public class MainActivity extends AppCompatActivity {
private DrawerLayout mDrawerLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
if (navigationView != null) {
setupDrawerContent(navigationView);
}
}
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
mDrawerLayout.closeDrawers();
return true;
}
});
}
}
盛装的抽屉 _ view. xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Section">
<menu>
<item
android:id="@+id/navigation_item_1"
android:icon="@drawable/ic_browncircle"
android:title="Sub item 1" />
</menu>
</item>
</menu>