简体   繁体   中英

customize action bar in android

I need to customize action bar to look like this photo

在此输入图像描述 when click on image of right it opens slide menu from right of screen , that works fine I tried that so far

getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.action_bar));
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

action_bar.xml

<?xml version="1.0" encoding="UTF-8"?>

<item>
    <shape
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/fb"
        android:shape="rectangle" >
        <solid android:color="#00C78C" />
    </shape>
</item>
<item>
    <bitmap
        android:gravity="center"
        android:src="@drawable/aslogo" />
</item>

and for search and setting icons i used this in main.xml

<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:showAsAction="never"

    android:title="@string/action_settings"/>

 <item
    android:id="@+id/action_help"
    android:icon="@drawable/assetting"
    android:showAsAction="always"/>

<item
    android:id="@+id/action_search"
    android:icon="@drawable/assearch"
    android:showAsAction="always"/>

here is what i have so far

在此输入图像描述

any help please

ok first of all .. remove your title with

getActionBar().setDisplayShowTitleEnabled(false);

then you should use orderInCategory in your xml file and it will order from less number to greater (from left side of your action bar) ...

If you are using Android's native Actionbar, proper RtL is only supported post Android 4.2: change action bar direction to right-to-left

If you want to support older Android versions, you probably have to customize one of the open source actionbar libraries, and use SlidingMenu for sliding from right action.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM