I have included a progress bar in each of my Action Bar tabs using a custom view. I would like the width of the progress bar to match the width of the tab indicator. However, the area covered by the custom view has margins set within the tab, so I'm unable to extend the progress bar to the full tab width. What's the best way to make this work?
Below is what it looks like now...

The progress bar is set to match the parent width.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="0dp"
>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tab_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text = "Day 1"
android:textAllCaps="true"
android:textStyle="bold"
android:textSize="13dp"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="18dp"
/>
<ProgressBar
style="@android:style/Widget.Holo.ProgressBar.Horizontal"
android:id="@+id/tab_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="1dp"
/>
</RelativeLayout>
The solution was to implement a custom theme for androidActionBarTabStyle. This is the contained for the view defined when using setCustomView One thing I ran into is that when creating a style as a theme, it must be prefixed by Theme, for example: Theme.MyTheme
If you do not include the Theme. prefix, your theme won't be applied.
Within the style file I defined this style:
<style name="withProgress" parent="@android:style/Widget.Holo.Light.ActionBar.TabView.Inverse">
<item name="android:padding">0dp</item>
</style>
And then in the theme.
<item name="android:actionBarTabStyle">@style/withProgress</item>
As it turned out, it looks pretty bad, but in case anyone is looking for something similar, that's how it's done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With