Friday, April 11, 2014

Example for Custom progress indicator in android



Example for Custom progress indicator in android 


This post about how to show custom indication for progress instead of showing default one
  

Create Style and shape for progress indicator

progress.xml
<?xmlversion="1.0"encoding="utf-8"?>
<rotatexmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
<shape
android:shape="oval"
android:useLevel="false">
<gradient
android:centerColor="#0099CC"
android:centerY="0.5"
android:endColor="#33B5E5"
android:startColor="#0099CC"
android:type="sweep"
android:useLevel="false"/>
</shape>
</rotate>


Set progress bar indeterminateDrawable is your custom progress.xml
android:indeterminateDrawable="@drawable/progress"


main.xml
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:layout_gravity="center"
android:background="@android:color/darker_gray"
tools:context="com.example.myfirstgrandapp.MainActivity$PlaceholderFragment">

<ProgressBar
android:id="@+id/progressBar2"
android:layout_width="55dp"
android:layout_height="55dp"
android:indeterminateDrawable="@drawable/progress"
android:layout_marginTop="30dp"
android:progress="0"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="Hooo! Its Loading wait for a moment..."/>
</LinearLayout>

 

No comments:

Post a Comment

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...