getSupportActionBar().setCustomView(view) does not fill entire actionbar getSupportActionBar().setCustomView(view) does not fill entire actionbar android android

getSupportActionBar().setCustomView(view) does not fill entire actionbar


This is all you need to add in your onCreate()

getSupportActionBar().setCustomView(new CustomView(this));getSupportActionBar().setDisplayShowCustomEnabled(true);


Set your main container to this:

   <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 the android:layout_gravity="fill_horizontal that should solve your problem.

EDIT:

if that did not work try doing 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); 


Custom views only occupy the area between the nav/up button and the overflow menu. To change the background and other colors see this - https://developer.android.com/training/basics/actionbar/styling.html