Progress Button Based on CardView
Progress Button Based on CardView
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.giorgi-abashidze:ProgressButtonCard:2.0'
}
“Button” is based on a CardView, you can use every property that
CardView have, for example cardElevation, cardBackgroundColor.
<ga.progress_button_card.Default
app:cardBackgroundColor="@color/colorPrimary"
android:id="@+id/progress_button_card"
app:cardElevation="3dp"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="50dp"
app:PBC_Text="Click me"
app:PBC_TextSize="16"
app:PBC_Radius="10dp"
app:PBC_TextColor="#ffffff"
></ga.progress_button_card.Default>
<ga.progress_button_card.Gradient
android:id="@+id/progress_button_card_gradient"
app:cardElevation="3dp"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="50dp"
app:PBC_StartColor="#CD3333"
app:PBC_EndColor="#FA7474"
app:PBC_TextSize="16"
app:PBC_Text="Click me"
app:PBC_Radius="10dp"
app:PBC_TextColor="#ffffff"
app:PBC_Gradient_Orientation="top_bottom"
></ga.progress_button_card.Gradient>
Databinding is only supported for field PBC_Text.
example: app:PBC_Text”@{someValue}”
ga.progress_button_card.Default button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = findViewById(R.id.progress_button_card);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
button.loading();
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
button.notLoading();
}
}, 5000);
}
});
}