Fabian Fabian - 1 month ago 14
Android Question

Android progressbar in button

Is there any possibility to show a spinning progress bar in a button?
e.g. as background drawable?

Answer

Yes.

You can create an AnimationDrawable, as described here, and then use the drawableLeft tag (for example) in your button's XML. like so:

<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/your_background_drawable_resource"
        android:drawableLeft="@drawable/your_animation_drawable_resource"
        android:text="@string/your_text_res">
</Button>
Comments