I want to make circular progress bar inside button.
but I don't want to use library like dmytrodanylyk/circular-progress-button, etc..
I think this solution is used drawable
.
so, i make circular_progress.xml
,
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1"
android:toDegrees="360" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false" >
<size
android:height="48dip"
android:width="48dip" />
<gradient
android:centerColor="#f0f0f0"
android:centerY="0.50"
android:endColor="#000000"
android:startColor="#ffffff"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
and,
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Log In"
android:layout_below="@+id/passwordWrapper"
android:layout_marginTop="5dp"
android:theme="@style/AppTheme.SignButton"
android:id="@+id/loginButton"
android:drawableRight="@drawable/circular_progress"
/>
but, progress bar is stopped.
second solution is to make custom button class having progressbar.
but i don't know to make custom button class having progressbar.
Use ProgressBar inside your button like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Log In"
android:layout_below="@+id/passwordWrapper"
android:layout_marginTop="5dp"
android:theme="@style/AppTheme.SignButton"
android:id="@+id/loginButton"
/>
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
and in your activity initialize the ProgressBar like this
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
and add this when you want the ProgressBar to be visible
progressBar.setVisibility(View.VISIBLE);
and then add this when you want to hide your ProgressBar
progressBar.setVisibility(View.GONE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With