Define your main container as follows:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_gravity="fill_horizontal" android:background="@color/actionbar_color" > <ImageView android:layout_width="wrap_content" android:layout_height="25dp" android:layout_centerInParent="true" android:scaleType="fitCenter" android:src="@drawable/logo"/> </RelativeLayout>
The important part is android:layout_gravity="fill_horizontal , which should solve your problem.
EDIT:
if this does not work, try to do this:
View view = getLayoutInflater().inflate(R.layout.actionbar_customized_home, null); LayoutParams layout = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); getSupportActionBar().setCustomView(view, layout);
source share