Search code examples
androidactionbarsherlockloadingtitlebar

setProgressBarIndeterminateVisibility changing custom title bar view width


When using ActionBarSherlock(ABS) setProgressBarIndeterminateVisibility(true|false) the custom title view width is changed, which is probably caused by the fact that ABS sets the indeterminate visibility to gone instead of invisibile.

I see too solutions, that I'm still working in:

  • set a custom indeterminate bar that belongs to the customView, but the visual effect wouldn't be so nice;

  • having a way to mess with ABS code that doesn't set the bar visibility to gone...

Is there any way of fixing this?


Solution

  • As I predicted, ABS changes the visibility to gone.

    Ii've chosen the second option, which is a quite simple solution. I downloaded the ABS code, imported it and changed the class ActionBarSherlockCompat

    Where is View.INVISIBLE was View.GONE before.

    Method:

    public class ActionBarSherlockCompat .... {
       private void updateProgressBars(int value) {
    
       ...
       else if (value == Window.PROGRESS_VISIBILITY_OFF) {
                if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) {
                    horizontalProgressBar.setVisibility(View.INVISIBLE);
                }
                if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) {
                    circularProgressBar.setVisibility(View.INVISIBLE);
                }
       ...
       }
    }