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:
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:
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:
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?