Custom circular progress bar is not working as expected.

104 views Asked by At

i am working on custom progress bar which will fades one-by-one so its give us feel like moving circular progress. For this i have declare this xml file

    <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" 
        android:id="@+id/customsearcl_ll"
>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginRight="15dp"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/circle1_imgv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:src="@drawable/circle_shape_big_custom_search" />

    <ImageView
        android:id="@+id/circle2_imgv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:src="@drawable/circle_shape_big_custom_search" />
</LinearLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/circle3_imgv"
        android:layout_width="wrap_content"
        android:layout_height="72dp"
        android:src="@drawable/circle_shape_big_custom_search" />

    <ImageView
        android:id="@+id/circle4_imgv"
        android:layout_width="wrap_content"
        android:layout_height="72dp"
        android:src="@drawable/circle_shape_big_custom_search" />
</LinearLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginLeft="15dp"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/circle5_imgv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:src="@drawable/circle_shape_big_custom_search" />

    <ImageView
        android:id="@+id/circle6_imgv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:src="@drawable/circle_shape_big_custom_search" />
</LinearLayout>

When you see above xml file you will feel that here no any

             android:alpha

is called.So for changing alpha i declare images as follow

    image1 = (ImageView)findViewById(R.id.circle3_imgv);
    image2 = (ImageView)findViewById(R.id.circle5_imgv);
    image3 = (ImageView)findViewById(R.id.circle6_imgv);
    image4 = (ImageView)findViewById(R.id.circle4_imgv);
    image5 = (ImageView)findViewById(R.id.circle2_imgv);
    image6 = (ImageView)findViewById(R.id.circle1_imgv);

    i = 0;
    alpha = (float).8;


   imaArray = new ImageView[] {image1 ,image2,image3,image4,image5, image6};

and after that declare timer as

   final CountDownTimer Counter1 = new CountDownTimer(500 , 500) { 
      public void onTick(long millisUntilFinished) {
        changeAlpha();     
      }

      public void onFinish() {
          Counter1.start(); 

      }
      };

Then inside onCreate() called Counter1.start(); So its invoking counter and inside counter called changeAlpha() method.

      void changeAlpha(){
        imaArray[i].setAlpha(alpha);
        alpha = (float) (alpha - .2);
        i++;    
        if(i ==5){
            i =0;
            alpha = (float) .8;
        }
       }

But problem is that its changing alpha of our drawable but only one time means that its not rotating again and again. Ones its complete 360 degress its stop but expectation is to rotate this images by alpha changing n-times.It will something look like as below

enter image description here

0

There are 0 answers