jmmontero
jmmontero

Reputation: 169

Android ProgressBar Indeterminate Not resize correctly

I create a custom Indeterminate ProgressBar with an animation, when I load in hdpi devices I get this.

https://i.sstatic.net/kfzQS.png

I want the logo appear one time.

This is my declaration in the XML

<ProgressBar
            android:id="@+id/loading"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:indeterminateDrawable="@anim/progressbaranimation"/>                                

And this is my Animation

<?xml version="1.0" encoding="utf-8" ?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:drawable="@drawable/icon_progress_dialog_drawable_0" android:duration="75" />
  <item android:drawable="@drawable/icon_progress_dialog_drawable_1" android:duration="75" />
  <item android:drawable="@drawable/icon_progress_dialog_drawable_2" android:duration="75" />
  <item android:drawable="@drawable/icon_progress_dialog_drawable_3" android:duration="75" />
  <item android:drawable="@drawable/icon_progress_dialog_drawable_4" android:duration="75" />
  <item android:drawable="@drawable/icon_progress_dialog_drawable_5" android:duration="75" />
  <item android:drawable="@drawable/icon_progress_dialog_drawable_6" android:duration="75" />
  <item android:drawable="@drawable/icon_progress_dialog_drawable_7" android:duration="75" />
</animation-list>

Upvotes: 1

Views: 1039

Answers (1)

bugraoral
bugraoral

Reputation: 2670

Your drawables are not resized correctly by progressbar. When there is more room, progressbar replicates its drawable, respectively when there is not enough room only draws partially. I have no idea why.

You can solve this by scaling the drawables.

<item android:duration="75">
   <scale
            android:drawable="@drawable/icon_progress_dialog_drawable_0"
            android:scaleGravity="center" />
</item>

Upvotes: 2

Related Questions