Skip to content Skip to sidebar Skip to footer

Problems With Icon_drawable In Navegation Drawable

I am trying to show Icon_drawble in a ActionBar, but when R.drawable.ic_drawer is in the first position show return arrow in actionbar. like this: mDrawerLayout = (DrawerLayout) f

Solution 1:

This appears to be a bug in recent versions of the AppCompat library.

Part of the confusion is likely due to the fact that Android Studio's new project wizard generates bad code when you create a new navigation drawer activity- it uses the v4 support library ActionBarDrawerToggle, which is deprecated. Instead, it should use the v7 support library ActionBarDrawerToggle.

You have two options:

  • The best option is to switch to the v7 ActionBarDrawerToggle. To do this, change your imports to use android.support.v7.app.ActionBarDrawerToggle instead of android.support.v4.app.ActionBarDrawerToggle. The only other change you should need to make is removing your ic_drawer parameter altogether- the newer version of the toggle generates the hamburger you are looking for automatically.

  • If you insist on using the v4 toggle or a custom icon, you can revert to an older version of the support library. Using the default generated project when creating a new navigation drawer activity, I was able to sidestep this bug by reverting to com.android.support:appcompat-v7:22.1.0 in my build.gradle.

There is already a bug in the issue tracker for updating the wizard-generated code. I wouldn't expect the v4 toggle to get fixed since it is deprecated.

Post a Comment for "Problems With Icon_drawable In Navegation Drawable"