Android ActionBar — How to add logo in centrelly aligned

I am new in android development and I want make a navigation drawer for my client.

How can I add a logo to my action bar in navigation drawer and remove the title.

my code :

Activity

 public void restoreActionBar() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#D5D2D4")));
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(mTitle);
    actionBar.setDisplayUseLogoEnabled(true);
}

Manifest Activity

   <activity
        android:name=".activity.Grid_Home_Activity"
        android:label="@string/title_activity_grid__home_"
        android:theme="@style/Theme.ActionBarJp">
    </activity>

Styles

<style name="Theme.ActionBarJp" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarSize">60dp</item>
    <item name="logo">@drawable/logo</item>
    <item name="displayOptions">useLogo|showHome</item>
</style>

Can anyone help ?


Source: android

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.