按钮中的Android进度条

标签 android button progress-bar

是否有可能在按钮中显示旋转进度条? 例如作为背景可绘制对象?

最佳答案

我遇到了同样的问题,所以我为此创建了一个专门的按钮:LoadingProgressButton

像这样包含按钮:

    <br.com.simplepass.loading_button_lib.CircularProgressButton
android:id="@+id/btn_id"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:background="@drawable/circular_border_shape"
     app:spinning_bar_width="4dp" <!-- Optional -->
     app:spinning_bar_color="#FFF" <!-- Optional -->
     app:spinning_bar_padding="6dp" <!-- Optional -->

并像这样使用它:

    CircularProgressButton btn = (CircularProgressButton) findViewById(R.id.btn_id)
            btn.startAnimation(); 
                [do some async task. When it finishes]

                 //You can choose the color and the image after the loading is finished
                 btn.doneLoagingAnimation(fillColor, bitmap);
                 [or just revert de animation]
                 btn.revertAnimation();

enter image description here

关于按钮中的Android进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4774004/

相关文章:

progress-bar - 如何在Qt4中创建进度条?

android - 生成一个将自动关闭的对话框

android - 无法在 Android 谷歌浏览器浏览器中通过谷歌键盘输入

flutter - 如何从Stateless类中的onPressed调用StatefulWidget的方法?

android - 是否可以在同一个 button.xml 存档中定义具有背景可绘制行为的多个按钮?

java - 在执行代码之前未设置进度条可见性

android - 清除 AutoCompleteTextview 中的文本不起作用

android - 从广播发送一些数据到打开的 Activity

java - 按钮中的图像模糊,按钮忽略 setSize

android - 如何分别显示多个上传的上传进度 - Android