问题
Can someone suggest how to implement progress dialog inside a Button
for example , when I click on submit Button
then progress dialog occurs inside Button
for showing loading
I don't want to block other UI elements
回答1:
You may go with Nilesh answer or if you're not willing to use third party lib, it is quite easy to write your own. All you have to do is to create a custom view extending RelativeLayout or FrameLayout.
This link might might help.
回答2:
See this link for Progress Button library
Include Progress Button in your layout like this
<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" />
回答3:
You can use this library: https://github.com/dmytrodanylyk/circular-progress-button
Just add this to build.gradle
:
dependencies {
compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
}
And then you can use this code in your .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" />
来源:https://stackoverflow.com/questions/31273535/progressbardialog-inside-a-button-android