Home > Software design >  Android material button with spinning icon
Android material button with spinning icon

Time:12-07

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

Thanks.

CodePudding user response:

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.

CodePudding user response:

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));
  • Related