I customize the view in the action bar. It fills the width of the action bar when using the SDK action bar, but not when using the appcompat version. Why doesn't my line layout fill the width when using appcompat and toolbar? And what can I do with it?
Here it looks like pre-appcompat:

And here is how it looks with appcompat. (The red color indicates the size of my custom view.):

Edit: Here is what it looks like using the params @Seidan hint. (Shows black text where it should be white):

Here is my custom layout:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:background="#800" > <FrameLayout android:id="@+id/actionbar_discard" style="?attr/actionButtonStyle" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" > <TextView style="?android:actionBarTabTextStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:drawableLeft="@drawable/ic_close_white_24dp" android:drawablePadding="8dp" android:gravity="center_vertical" android:paddingRight="20dp" android:text="@string/actionbar_cancel" /> </FrameLayout> <FrameLayout android:id="@+id/actionbar_done" style="?attr/actionButtonStyle" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" > <TextView style="?android:actionBarTabTextStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:drawableLeft="@drawable/ic_check_white_24dp" android:drawablePadding="8dp" android:gravity="center_vertical" android:paddingRight="20dp" android:text="@string/actionbar_done" /> </FrameLayout> </LinearLayout>
And this is how I customize the action bar:
ActionBar ab = getSupportActionBar(); ab.setDisplayHomeAsUpEnabled(false); ab.setDisplayOptions( ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); ab.setCustomView(R.layout.actionbar_discard_done);
Both appcompat-v7: 22.0.0 and the new appcompat-v7: 22.1.0 demonstrate this problem.
source share