Indeterminate Progress in DarkActionBar

3,265 views
Skip to first unread message

Mark Andrachek, Jr.

unread,
Mar 8, 2012, 1:30:12 AM3/8/12
to actionba...@googlegroups.com
The default Indeterminate Progress indicator is, IMHO, too large. I much prefer the small one.

I figured out how to override this, and use Widget.Holo.ProgressBar.Small for v14+, but it appears there's no Widget.Sherlock.ProgressBar.Small.
So I copied the necessary assets from the SDK into my project, and created a values/styles.xml that looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<resources>

<style name="Light" parent="@style/Theme.Sherlock.Light.DarkActionBar">

    <item name="android:actionBarStyle">@style/ActionBarIPS</item>

</style>

<style name="IndeterminateProgress" parent="@style/Widget.Sherlock.ProgressBar">

    <item name="android:indeterminateDrawable">@drawable/progress_small_holo</item>

</style>

<style name="ActionBarIPS" parent="@style/Widget.Sherlock.Light.ActionBar.Solid.Inverse">

    <item name="android:indeterminateProgressStyle">@style/IndeterminateProgress</item>

</style>

</resources>


And a values-v14/styles.xml that looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<resources>

<style name="Light" parent="@android:style/Theme.Holo.Light.DarkActionBar">

    <item name="android:actionBarStyle">@style/ActionBarIPS</item>

</style>

<style name="IndeterminateProgress" parent="@android:style/Widget.ProgressBar.Small"/>

<style name="ActionBarIPS" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">

    <item name="android:indeterminateProgressStyle">@style/IndeterminateProgress</item>

</style>

</resources>


This gives me the small progress drawable on ICS, but the emulator running 2.3.1, doesn't seem to pick up on the change. In fact, I tried changing out the drawable, so I could see if it was doing anything, and it doesn't appear to be.


So, question is, how can I get the small indeterminate progressbar in pre-ICS with the Light.DarkActionBar theme?


FWIW, I'm using ABS 4.0RC1, with support plugin.


Thanks,

Mark 

Shaver Sport

unread,
Mar 9, 2012, 12:03:16 AM3/9/12
to actionba...@googlegroups.com
Looks good, just override the styles that ABS uses when it's running, for example:

<style name="Light" parent="@style/Theme.Sherlock.Light.DarkActionBar">

    <item name="android:actionBarStyle">@style/ActionBarIPS</item>
    <item name="actionBarStyle">@style/ActionBarIPS</item>

</style>

Jake Wharton

unread,
Mar 9, 2012, 12:04:43 AM3/9/12
to actionba...@googlegroups.com
What he said. You just need to apply it to a non-prefixed version of the theme attribute so the compatibility action bar picks it up.

---
Jake Wharton
http://about.me/jakewharton

Mark Andrachek, Jr.

unread,
Mar 14, 2012, 8:15:07 PM3/14/12
to actionba...@googlegroups.com
Ok. I've tried this. It's now using my images! Thanks!

But the scaling is messed up. I have the hdpi and mdpi spinner_16_inner/outer_holo pngs from sdk 15 in their respective folders. And I copied the progress_small_holo.xml file for the layer list, from the sdk to my drawable directory.

It seems like it's always blowing the image up to fill the actionbar.  Or, rather, it's scaling the image to match some expected size.

The actionbar icon guideline docs state that icons should be 36x36 @ hdpi here http://developer.android.com/guide/practices/ui_guidelines/icon_design_action_bar.html, however the design site says they should be 32dp (32px @mdpi, 48px @hdpi). 

The indeterminateProgressDrawable isn't an icon, and doesn't appear to follow these rules in the native actionbar on  ICS, but it seems like this is what is happening with ABS.

Which size should I use at hdpi for ABS - 36x36, 48x48, or some other config?


Thanks,
Mark

PS, my working styles.xml now looks like:.

<?xml version="1.0" encoding="UTF-8"?>

<resources>

<style name="Light" parent="@style/Theme.Sherlock.Light.DarkActionBar">

    <item name="actionBarStyle">@style/ActionBarIPS</item>

    <item name="android:actionBarStyle">@style/ActionBarIPS</item>

</style>

<style name="ActionBarIPS" parent="@style/Widget.Sherlock.Light.ActionBar.Solid.Inverse">

    <item name="indeterminateProgressStyle">@style/IndeterminateProgress</item>

    <item name="android:indeterminateProgressStyle">@style/IndeterminateProgress</item>

</style>

<style name="IndeterminateProgress" parent="@style/Widget.Sherlock.ProgressBar">

    <item name="android:indeterminateDrawable">@drawable/smallprogress</item>

</style>

</resources>

Thomas Bouron

unread,
Mar 22, 2012, 4:35:31 AM3/22/12
to actionba...@googlegroups.com
Hi!

I found this post through https://github.com/JakeWharton/ActionBarSherlock/issues/387 and i got the same issue here. It seems impossible to change the indeterminate progressbar size as it scales to fit the area.
Is there any solution/suggestion to fix this issue?

Thanks!

PS: I didn't create a ticket on GitHut as i don't have an account there.

Jake Wharton

unread,
Mar 28, 2012, 12:12:02 PM3/28/12
to actionba...@googlegroups.com
Try something like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:addStatesFromChildren="true"
              android:focusable="true"
              android:paddingLeft="4dp"
              android:paddingRight="4dp"
              android:gravity="center"
              style="?attr/actionButtonStyle">
    <ProgressBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:focusable="true"
            style="@android:style/Widget.ProgressBar.Small"/>
</LinearLayout>

Emanuel Moecklin

unread,
Mar 28, 2012, 12:32:11 PM3/28/12
to ActionBarSherlock
Or take this from the Android sources:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<ProgressBar android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_gravity="center"
style="?android:attr/indeterminateProgressStyle" />
</FrameLayout>

Works nicely on 2.x, 3.x and 4.x.

thanksmister

unread,
Mar 30, 2012, 7:02:01 PM3/30/12
to actionba...@googlegroups.com

You could do something like this (modifying your code for dark theme).  This uses the progress_small_holo.xml and associated images from the Android SDK (15):

    <style name="Dark" parent="Theme.Sherlock">

        <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>

        <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

    </style>

    <style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar">

        <item name="android:indeterminateProgressStyle">@style/IndeterminateProgress</item> 

    </style>

    <style name="IndeterminateProgress" parent="@android:style/Widget.ProgressBar.Small"> 

    <item name="android:indeterminateDrawable">@drawable/progress_small_holo</item> 

</style> 

Michael Ritchie

unread,
Mar 30, 2012, 8:10:14 PM3/30/12
to actionba...@googlegroups.com
Forgot one detail for non-prefixed versions:

<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar">

        <item name="android:indeterminateProgressStyle">@style/IndeterminateProgress</item> 

        <item name="indeterminateProgressStyle">@style/IndeterminateProgress</item> 

    </style>

Michael Vogt

unread,
Apr 14, 2012, 6:33:10 AM4/14/12
to actionba...@googlegroups.com
Hi.

I followed your blog entry on this ( http://thanksmister.com/2012/03/30/change-default-progress-actionbarsherlock/ ), but the progress circle still shows up large and not small. I set the theme in the manifest to Theme.Sherlock. Is there anything else I need to set?

Thanks

Michael Vogt

unread,
May 28, 2012, 6:05:01 PM5/28/12
to actionba...@googlegroups.com
This is still not working for me. 

I put progress_small_holo.xml in the /drawable folder. I put the two PNG files in the various drawable folders (/drawable-*). My manifest has android:theme="@style/Theme.Sherlock" included in the application section. Yet still, my indeterminate progressbar is not small. when running version 8 (2.2) or 14 (ICS) Any idea what I'm missing?

Jake Wharton

unread,
May 28, 2012, 6:21:45 PM5/28/12
to actionba...@googlegroups.com
You need a custom progress style which inherits from Widget.Sherlock.ProgressBar and sets the drawable to your custom XML. Then you need to refer to that style in the indeterminateProgressStyle attribute of a custom action bar style. You can then specify that custom action bar style in a theme which extends a sherlock theme and update your manifest to use it.

Make sure you are using both android prefixed and unprefixed attributes in both the theme and action bar style so that it's picked up on both pre-ICS and post-ICS.

Michael Vogt

unread,
May 28, 2012, 10:33:53 PM5/28/12
to actionba...@googlegroups.com
Thank you for your reply. I *think* I am doing this already, but it's still not working for me.

<resources>


<style name="Dark" parent="Theme.Sherlock">
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>

<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:indeterminateProgressStyle">@style/IndeterminateProgress</item>

<item name="indeterminateProgressStyle">@style/IndeterminateProgress</item>
</style>

<style name="IndeterminateProgress" parent="Widget.Sherlock.ProgressBar">

<item name="android:indeterminateDrawable">@drawable/progress_small_holo</item>
</style>

</resources>

Reply all
Reply to author
Forward
0 new messages