I’m using actionbarsherlock to do it.
Example of what I want in the actionbar:
[LOGIN] [COMPANY LOGO] [FILTER]
Example of what I get in the actionbar:
[LOGIN] [COMPANY LOGO] [FILTER]
I have created the login button, company logo and filter button (in the form of drawables) in the res/menu’s activity_main.xml. However, those buttons on the actionbar are unable to shift fully to the left, even though I have removed the default application logo and set those to false:
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled (false);
here are my codes in the menu’s activity_main.xml:
<item android:id="@+id/login"
android:icon="@drawable/login_btn"
android:layout_gravity="left"
android:showAsAction="always"/>
<item android:id="@+id/logo"
android:icon="@drawable/logo_btn"
android:layout_gravity="center"
android:showAsAction="always"/>
<item android:id="@+id/filter"
android:icon="@drawable/filter_btn"
android:layout_gravity="right"
android:showAsAction="always"/>
You should create custom view for that. For example (
layout/ab_custom.xml):Then in your Activity’s
onCreatecall this method:To take control on your items use this:
EDIT: revised my answer. It’s better to use
RelativeLayout as parent.