5

I just updated my android SDK in order to get the android 5 updates. Those are the steps I did:

  • Updated the android-SDK
  • Updated the eclipse plugins
  • Updated my project build target=21 and targetSdkVersion=21

Then I ran my app (wich uses the compat-v7 library) and found that the navigation drawer seems buggy. The app icon in the action bar is gone and the overall style seems incorrect (see the picture 2).

So I took the "Creating a Navigation Drawer" example and performed the following test:

Downloaded the sample project, updated the build target and targetSdk and replaced the android-support-v4.jar with the Compat-v7 library (revision 21) . Changed the ActionBarDrawerToggle import from android.support.v4... to import android.support.v7...

The result is correct:

Picture 1:

enter image description here

Then I try to swap the MainActivity parent class from Activity to ActionBarActivity, changing getActionBar() calls with getSupportActionBar() and getFragmentManager() with getSupportFragmentManager()

Also added the android:theme="@style/Theme.AppCompat" theme to the activity

It works but the app icon is missing and the options menu are not shown as an action. See screenshots below.

Picture 2:

enter image description here

How can I fix it?

UPDATES:

With the code:

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
getSupportActionBar().setDisplayShowHomeEnabled(true);

You get the following bar:

enter image description here

It is pretty ok but I preffer the compact version, where the drawer indicator/ arrow have no padding with the icon (see image below). How can I achieve it?

enter image description here

Addev
  • 31,819
  • 51
  • 183
  • 302
  • I have got the same issue with the toolbar eating up my menu options and putting them in the overflow menu:/ Have you found a solution for this ? – DrkStr Nov 12 '14 at 07:28

4 Answers4

2

This is actually the intended behavior for the new Material Design paradigm. According to the official documentation on Toolbar:

In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

Roberto Betancourt
  • 2,375
  • 3
  • 27
  • 35
1

Maybe this will help you:

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.drawable.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true);

UPDATE: You can find the answer for your second question here:

How to change Toolbar navigation icon and options menu margin

Community
  • 1
  • 1
Alexey
  • 4,384
  • 1
  • 26
  • 34
0

This is working as intended, the app icon is not displayed by default now. You can call the following to display the icon again.

ActionBar ab = getSupportActionBar();
ab.setHomeButtonEnabled(true);
Chris Banes
  • 31,763
  • 16
  • 59
  • 50
0

After you switch to new ActionBarActivity, it looks like it hides home/Logo of Actionbar. And the @style/Theme.AppCompat has not Logo by default. You can enable it with .setHomeButtonEnabled(true);

Sinan Kozak
  • 3,236
  • 2
  • 26
  • 32