-1

Is it possible to have a spinning icon (like progressbar) as the material button icon?

Thanks.

Sharas
  • 1,985
  • 3
  • 20
  • 43

2 Answers2

0

You can use a progress bar itself and add onclick event listener so that it can behave like a button add onClick="whenProgressBarIsClicked()" to your XML and below statement to your Java code

add

public void whenProgressBarIsClicked(){ 
//Do some wonderful stuff here
}

If you use Kotlin, you can replace the above code with your Kotlin code.

Soumil Tewari
  • 96
  • 1
  • 8
0

Yes you can implement on Button

I used it in Material FloatingButton.

Make this file SlideUp__Animation.xml in res/anim/ folder

   <set xmlns:android="http://schemas.android.com/apk/res/android">

          <translate
            android:duration="700"
            android:fromYDelta="90%"
            android:toYDelta="0"
    
           />
   </set>

Apply this in the main class's floating button.

fButton.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.slideup__animation));
a_local_nobody
  • 7,947
  • 5
  • 29
  • 51