0

I was trying to think of a more appropriate title for this thread but couldn't to describe my issue.

Here is the progressBar xml code I'm using:

<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/progressBar"
    android:layout_centerInParent="true"/>

Here is the code in my AppCompatActivity:

progressBar = (ProgressBar) findViewById(R.id.progressBar);
progressBar.setIndeterminate(true);

When the progressBar starts up, it looks like this - which looks like the outdated version of a progressBar:

progressBar

Then after a few seconds, it changes to this type of progressBar which looks like the new design:

progressBarnew

How can I get it to show the new design from the start as I don't want the older looking progressBar to be displayed?

This is the theme I'm using for my activity:

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="Theme.AppCompat.NoActionBar">

    <item name="android:windowBackground">@color/primary</item>
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/deep_orange_500</item>
    <item name="colorControlNormal">@color/iron</item>
    <item name="colorControlActivated">@color/white</item>
    <item name="colorControlHighlight">@color/white</item>
    <item name="android:textColorHint">@color/iron</item>
    <item name="colorButtonNormal">@color/primary_darker</item>
    <item name="android:colorButtonNormal">@color/primary_darker</item>
</style>

I have noticed that this occurs when I change the visibility of items within my layout. I have a login button that when clicked would hide everything and display the progressBar. When I click on the login button, the screen goes back to show the status bar at the top for a few seconds and the progressBar reflects the old non-material theme progressBar. When the status bar disappears again, the new progressBar appears on screen.

It makes me think that the theme is not honoured when visibility of items are changed?

Simon
  • 19,658
  • 27
  • 149
  • 217

2 Answers2

0

I think by mistake, I put in this style and attached it to the progressBar:

    style="@style/Widget.AppCompat.ProgressBar"

Deleting it make it revert back to the material theme progressBar

EDIT:

After further investigations, it is actually due to the progressBar included within the facebook SDK. I had to take it out by following the advice in this thread: Android: How to hide progress circle in Facebook login copied and pasted here for your convenience.

I had the same problem with facebook sdk 4.x. When I click the facebook login button the Facebook Activity appears translucent but it shows a progress bar. Luckily we can disable this progress bar in the theme. So the Facebook Activity is declared as

<activity
    android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />

All we have to do is create a style that inherits from Theme.Translucent.NoTitleBar and hides the progress bar:

<style name="FullyTranslucent" parent="android:Theme.Translucent.NoTitleBar">
    <item name="android:progressBarStyle">@style/InvisibleProgress</item>
</style>

<style name="InvisibleProgress">
    <item name="android:visibility">gone</item>
</style>

Now set the theme of the activity to our new theme:

<activity
    android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name"
    android:theme="@style/FullyTranslucent" />

Voila! The ProgressBar before login is gone.

Community
  • 1
  • 1
Simon
  • 19,658
  • 27
  • 149
  • 217
0

This is a good solution

style="@android:style/Widget.ProgressBar.Inverse"