Skip to content Skip to sidebar Skip to footer

Preparing Custom Action Bar

I am trying to get exactly like the below image. But I am able to get the below one right now. Here I have two questions. 1) How to make this actionbar to be worked on all activi

Solution 1:

1) How to make this actionbar to be worked on all activities instead of single activity that I am inflating now.

Add below code to your style.xml.

<stylename="Theme.Styled"parent="Theme.Sherlock.Light"><itemname="actionBarStyle">@style/Widget.Styled.ActionBar</item><itemname="android:actionModeCloseDrawable">@drawable/collapse_button</item><itemname="android:actionBarStyle">@style/Widget.Styled.ActionBar</item></style><stylename="Widget.Styled.ActionBar"parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse"><itemname="background">@drawable/ab_customshape</item><itemname="android:background">@drawable/ab_customshape</item></style>

Then set this as your app theme in your manifest like,

<application
    android:allowBackup="true"
    android:icon="@drawable/app_icon"
    android:label="@string/app_name"
    android:theme="@style/Theme.Styled" > //Here we set the theme

And try to add buttons to your actionbar like this,

@OverridepublicbooleanonCreateOptionsMenu(Menu menu) {


    menu.add(0, HOMEBUTTON, 0, "Home").setIcon(R.drawable.home_button)

    .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    returntrue;
}

enter image description here

and 9 patch here enter image description here

Post a Comment for "Preparing Custom Action Bar"