[英]Navigation Drawer icons not showing
I am using Android Studio's Navigation Drawer Template. 我正在使用Android Studio的导航抽屉模板。 I have replaced the icons and text in the navigation drawer menu with my own.
我用自己的导航抽屉菜单替换了图标和文本。 You can see the menu items' text just fine, but both icons are missing.
您可以看到菜单项的文本很好,但两个图标都丢失了。 I am, temporarily, using the same icon for both.
我暂时使用相同的图标。 The icon is a .png in my drawable folder, heart_full.
该图标是我的drawable文件夹heart_full中的.png。 (It is the same heart icon that you can see along the right side of the MainActivity behind the navigation drawer.)
(您可以在导航抽屉后面的MainActivity右侧看到相同的心形图标。)
Here is my navigation drawer menu: 这是我的导航抽屉菜单:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<item
android:id="@+id/nav_routes"
android:icon="@drawable/heart_full"
android:title="Routes"/>
<item
android:id="@+id/nav_favorites"
android:icon="@drawable/heart_full"
android:title="Favorites"/>
</group>
I setup the drawer in onCreate with the following code: 我使用以下代码在onCreate中设置抽屉:
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
Does any code look suspect or am I missing something altogether? 是否有任何代码看起来可疑,或者我完全错过了什么?
I had the following in my styles.xml: 我在styles.xml中有以下内容:
<item name="android:textColorSecondary">@android:color/white</item>
Apparently, it is also responsible for the color of navdraw menu icons. 显然,它还负责导航菜单图标的颜色。 White icons on white background are not visible.
白色背景上的白色图标不可见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.