项目作者: giorgi-abashidze

项目描述 :
Progress Button Based on CardView
高级语言: Java
项目地址: git://github.com/giorgi-abashidze/ProgressButtonCard.git
创建时间: 2020-07-05T15:13:57Z
项目社区:https://github.com/giorgi-abashidze/ProgressButtonCard

开源协议:

下载


ProgressButtonCard

Progress Button Based on CardView

Install (Gradle)

Add it in your root build.gradle at the end of repositories:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Step 2. Add the dependency

  1. dependencies {
  2. implementation 'com.github.giorgi-abashidze:ProgressButtonCard:2.0'
  3. }

Properties:

“Button” is based on a CardView, you can use every property that
CardView have, for example cardElevation, cardBackgroundColor.

  • PBC_Text provides the text of the button
  • PBC_TextStyle provides the style of the text. possible values is: bold, normal, italic default is normal
  • PBC_TextSize text size of button
  • PBC_TextColor provides te color of the button text ! This property working only with hex color strings like: #ffffff
  • PBC_Radius provides corner radius of the button

Button Gradient specific properties:

  • PBC_Gradient_Orientation provides orientation of a gradient. pssoble values is: top_bottom, left_right, bottomLeft_topRight, topLeft_bottomRight
  • PBC_StartColor provides the start color of a gradient ! This property working only with hex color strings like: #ffffff
  • PBC_EndColor provides the end color of a gradient ! This property working only with hex color strings like: #ffffff

Example in XML:

Default Button:

  1. <ga.progress_button_card.Default
  2. app:cardBackgroundColor="@color/colorPrimary"
  3. android:id="@+id/progress_button_card"
  4. app:cardElevation="3dp"
  5. android:layout_margin="10dp"
  6. android:layout_width="match_parent"
  7. android:layout_height="50dp"
  8. app:PBC_Text="Click me"
  9. app:PBC_TextSize="16"
  10. app:PBC_Radius="10dp"
  11. app:PBC_TextColor="#ffffff"
  12. ></ga.progress_button_card.Default>

Gradient Button:

  1. <ga.progress_button_card.Gradient
  2. android:id="@+id/progress_button_card_gradient"
  3. app:cardElevation="3dp"
  4. android:layout_margin="10dp"
  5. android:layout_width="match_parent"
  6. android:layout_height="50dp"
  7. app:PBC_StartColor="#CD3333"
  8. app:PBC_EndColor="#FA7474"
  9. app:PBC_TextSize="16"
  10. app:PBC_Text="Click me"
  11. app:PBC_Radius="10dp"
  12. app:PBC_TextColor="#ffffff"
  13. app:PBC_Gradient_Orientation="top_bottom"
  14. ></ga.progress_button_card.Gradient>

DataBinding

Databinding is only supported for field PBC_Text.

example: app:PBC_Text”@{someValue}”

You can switch loading and not loading modes with functions: loading() and notLoading()

Example:

  1. ga.progress_button_card.Default button;
  2. @Override
  3. protected void onCreate(Bundle savedInstanceState) {
  4. super.onCreate(savedInstanceState);
  5. setContentView(R.layout.activity_main);
  6. button = findViewById(R.id.progress_button_card);
  7. button.setOnClickListener(new View.OnClickListener() {
  8. @Override
  9. public void onClick(View v) {
  10. button.loading();
  11. final Handler handler = new Handler();
  12. handler.postDelayed(new Runnable() {
  13. @Override
  14. public void run() {
  15. button.notLoading();
  16. }
  17. }, 5000);
  18. }
  19. });
  20. }