简体   繁体   中英

How to modify the actionbar in android

I am trying to modify my Actionbar to look like shown 1 2 .

But I am having no success, can someone tell me how to go about it, the title is needed on the right and the font is also different

Any help will be appreciated. Thanks

You can set action background after API 11.

    ActionBar actionBar = getActionBar();
    Drawable drawable = getResources().getDrawable(R.drawable.dummy_action_bar);
    actionBar.setBackgroundDrawable(drawable);

This is an example of how you shouldn't do it!!! (see comments)

====================================================================

In AndroidManifest , add to your activity theme attribute with no Action Bar:

android:theme="@android:style/Theme.Holo.Light.NoActionBar"

Add RelativeLayout to your layout, with blue background and ImageView containing logo on the right.

<RelativeLayout 
    android:id="@+id/fakeActionBar"
    android:layout_width="fill_parent"
    android:layout_height="48dp"
    android:background="#F00A"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    >

    <ImageView
    android:layout_width="100dp"
    android:layout_height="48dp"
    android:layout_alignParentRight="true"
    android:src="@drawable/logo_top"
    />
</RelativeLayout>

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