Custom circular ProgressBar with image in center [closed]
Asked Answered
G

2

5

For my android application I want put an image in a circular progress bar. Expected design:

http://hpics.li/cd6acba

Any ideas on how to do that?

Grudging answered 24/3, 2015 at 9:54 Comment(0)
G
5

You can take a normal layout file: loader.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:clickable="false">

    <ProgressBar
        android:id="@+id/progressBar1"
        style="@android:style/Widget.ProgressBar.Small.Inverse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        android:layout_centerInParent="true"
        android:padding="30dp"
        android:clickable="false"/>

    <ImageView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/img"
        android:clickable="false"/>

</RelativeLayout>

Do the little adjustment according to your design.

Now use this layout as your progress dialog drawable.

Gasworks answered 24/3, 2015 at 10:4 Comment(2)
The opening tag is a RelativeLayout but the closing tag is a LinearLayout. I don't think that would compile.Swenson
Nice catch. Have modified the code. @SriramGasworks
C
7
  1. Create the animation xml :

    <?xml version="1.0" encoding="utf-8"?>
    <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:drawable="@drawable/progress_bar"
        android:pivotX="50%"
        android:pivotY="50%" />
    
  2. Set the following to your progressbar view in layout xml:

    android:indeterminateDrawable="@animator/progressbar_animation"
    
Centaury answered 24/3, 2015 at 9:58 Comment(0)
G
5

You can take a normal layout file: loader.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:clickable="false">

    <ProgressBar
        android:id="@+id/progressBar1"
        style="@android:style/Widget.ProgressBar.Small.Inverse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        android:layout_centerInParent="true"
        android:padding="30dp"
        android:clickable="false"/>

    <ImageView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/img"
        android:clickable="false"/>

</RelativeLayout>

Do the little adjustment according to your design.

Now use this layout as your progress dialog drawable.

Gasworks answered 24/3, 2015 at 10:4 Comment(2)
The opening tag is a RelativeLayout but the closing tag is a LinearLayout. I don't think that would compile.Swenson
Nice catch. Have modified the code. @SriramGasworks

© 2022 - 2024 — McMap. All rights reserved.