按钮内的 ProgressBar(Dialog) android

ProgressBar(Dialog) inside a Button android

有人可以建议如何在 Button 中实现 进度对话框 例如,当我单击提交 Button 时, 进度对话框 出现在 Button 内以显示加载 我不想屏蔽其他 UI 元素

看到这个 link Progress Button library

像这样在布局中包含进度按钮

 <com.dd.processbutton.iml.ActionProcessButton
            android:id="@+id/btnSignIn"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_marginBottom="16dp"
            android:text="@string/Sign_in"
            android:textColor="@android:color/white"
            android:textSize="18sp"
            custom:pb_colorComplete="@color/green_complete"
            custom:pb_colorNormal="@color/blue_normal"
            custom:pb_colorPressed="@color/blue_pressed"
            custom:pb_colorProgress="@color/purple_progress"
            custom:pb_textComplete="@string/Success"
            custom:pb_textProgress="@string/Loading" />

您可以选择 Nilesh 的答案,或者如果您不愿意使用第三方库,编写您自己的库也很容易。您所要做的就是创建一个扩展 RelativeLayout 或 FrameLayout 的自定义视图。

这个 link 可能会有所帮助。

您可以使用这个库: https://github.com/dmytrodanylyk/circular-progress-button

只需将此添加到 build.gradle:

dependencies {
    compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
}

然后您可以在您的 .xml:

中使用此代码
<com.dd.CircularProgressButton
        android:id="@+id/circularButton1"
        android:layout_width="196dp"
        android:layout_height="64dp"
        android:textColor="@color/cpb_white"
        android:textSize="18sp"
        app:cpb_cornerRadius="48dp"
        app:cpb_iconComplete="@drawable/ic_action_accept"
        app:cpb_iconError="@drawable/ic_action_cancel"
        app:cpb_textIdle="@string/Upload" />