1
我正在使用Android Studio的导航抽屉模板。我用自己的菜单替换了抽屉菜单中的图标和文字。你可以看到菜单项的文字很好,但两个图标都丢失了。我暂时使用相同的图标。该图标是我的可绘制文件夹heart_full中的一个.png。 (这是相同的心脏图标,你可以沿着导航抽屉后面在MainActivity的右侧看到的。)导航不显示抽屉图标
这里是我的抽屉式导航菜单:
<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>
我使用以下代码在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);
是否有任何代码看起来嫌疑或者我完全错过了什么?