Similar to the question here, but has some key differences. Most notably being that the accepted answer did work until the latest support library releases.
Here's the custom view layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFDD0000">
</LinearLayout>
Now, when you try to set just the custom view:
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.actionbar);
You end up with a custom layout that doesn't fill the entire width:
To make this more interested, I have a similar setup in a different app:
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.actionbar);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(false);
This did work, until I updated the support libraries to v21. Once I did, I ended up with the same issue on apps that previously haven't had that issue.
So, my question is, is there a way to make a custom view actionbar fill the width using the latest support library?
Edit After doing some more tests, I found that compiling with targetSdkVersion/compileSdkVersion set to 19 and having v7:19.0.1 (or v7:19.1.0) for the library doesn't have this issue (has the home icon, which is taken care of with the later code), confirming that this is definitely an issue with the latest release.