Reputation: 1196
I have tried all code but i can't find solution how use this (GIF)image in my progessbar
XML file
<ProgressBar
android:id="@+id/progressBar"
style="@style/GenericProgressIndicator"
android:layout_width="fill_parent"
android:layout_height="200px"
android:layout_centerInParent="true"
android:visibility="visible"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminateDrawable="@drawable/animation" >
</ProgressBar>
JAVA File
ProgressBar bar=(ProgressBar)findViewById(R.id.progressBar);
Want to use this image in progress bar
Upvotes: 0
Views: 7980
Reputation: 3349
<ImageView
android:id="@+id/ivProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible" />
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item
android:drawable="@mipmap/wblod_0"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_1"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_2"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_3"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_4"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_5"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_6"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_7"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_8"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_9"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_10"
android:duration="40" />
<item
android:drawable="@mipmap/wblod_11"
android:duration="40" />
</animation-list>
private AnimationDrawable animationDrawable;
private ImageView mProgressBar;
mProgressBar.setBackgroundResource(R.drawable.loading_web_animation);
animationDrawable =(AnimationDrawable)mProgressBar.getBackground();
mProgressBar.setVisibility(View.VISIBLE);
animationDrawable.start();
mProgressBar.setVisibility(View.GONE);
animationDrawable.stop();
Upvotes: -1
Reputation: 901
You don't need to use ProgressBar to show a GIF, unless you want to use special functionality that ProgressBar provides (does not look like it).
It's enough to use simple ImageView and some image library that supports GIFs (eg Glide).
Upvotes: 3
Reputation: 990
this is a trick instead of a full solution i load the gif as an image in alert dialog box with transparent background and show this alert dialog at start of process and dismiss it at the end.
However have a look at this too: Custom circular ProgressBar with image in center
Upvotes: 1