|
1 | | -# Plus-Minus-Quantity-Card-Android-Library |
| 1 | +# Plus-Minus Quantity Card Library Android |
| 2 | + |
| 3 | + |
| 4 | +A simple and fun UI widget cardview for displaying a plus-minus animated quantity layout. |
| 5 | +You can customize the plus & minus views! Setting image drawables for plus & minus available. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## Including into your project |
| 10 | + |
| 11 | +### Gradle |
| 12 | + |
| 13 | +Add below codes to your <b>root</b> settings.gradle file. |
| 14 | + |
| 15 | +``` |
| 16 | +allprojects { |
| 17 | + repositories { |
| 18 | + ... |
| 19 | + maven { url 'https://jitpack.io' } |
| 20 | + } |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +And add a dependency code to your <b>module</b>'s build.gradle file. |
| 25 | + |
| 26 | +``` |
| 27 | +dependencies { |
| 28 | + implementation 'com.github.radustavila:Plus-Minus-Quantity-Card-Android-Library:1.0' |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +## Usage |
| 33 | + |
| 34 | +- Default in your xml file: |
| 35 | + |
| 36 | +``` |
| 37 | + <com.radustavila.qunatitycardlibrary.QuantityCardView |
| 38 | + android:id="@+id/quantity_card" |
| 39 | + android:layout_width="wrap_content" |
| 40 | + android:layout_height="wrap_content" |
| 41 | + /> |
| 42 | +``` |
| 43 | + |
| 44 | +- Custom in your xml file: |
| 45 | + |
| 46 | +``` |
| 47 | + <com.radustavila.qunatitycardlibrary.QuantityCardView |
| 48 | + android:id="@+id/second_card" |
| 49 | + android:layout_width="200dp" |
| 50 | + android:layout_height="65dp" |
| 51 | + android:layout_margin="20dp" |
| 52 | + android:textSize="7sp" |
| 53 | + android:textColor="@color/teal_700" |
| 54 | + app:decreaseTextColor="@color/purple_200" |
| 55 | + app:increaseTextColor="@color/purple_700" |
| 56 | + app:decreaseTextSize="13sp" |
| 57 | + app:increaseTextSize="13sp" |
| 58 | + app:startingQuantity="1" |
| 59 | + app:minQuantity="0" |
| 60 | + app:maxQuantity="10" |
| 61 | + app:reverseAnimation="false" |
| 62 | + app:transitionDuration="300" |
| 63 | + app:layoutBackgroundColor="@color/gray" |
| 64 | + /> |
| 65 | +``` |
| 66 | + |
| 67 | +- Cusotm in your Activity/Fragment/View file: |
| 68 | + |
| 69 | +``` |
| 70 | + val quantityCard: QuantityCardView = findViewById(R.id.third_card) |
| 71 | + quantityCard.width = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250f, resources.displayMetrics).toInt() |
| 72 | + quantityCard.height = 250 |
| 73 | + quantityCard.setMinQuantity(1000) |
| 74 | + quantityCard.setMaxQuantity(7777) |
| 75 | + quantityCard.setStartingQuantity(99999) |
| 76 | + quantityCard.setTextColor(Color.WHITE) |
| 77 | + quantityCard.setLayoutBackgroundColor(Color.BLACK) |
| 78 | + quantityCard.setTextSize(30f) |
| 79 | + quantityCard.setTransitionDuration(500) |
| 80 | + quantityCard.setReverseAnimation(true) |
| 81 | + quantityCard.setIncreaseImage(AppCompatResources.getDrawable(this, R.drawable.plus)) // Add your own drawable! |
| 82 | + quantityCard.setDecreaseImage(AppCompatResources.getDrawable(this, R.drawable.minus)) // Add your own drawable! |
| 83 | +``` |
| 84 | + |
| 85 | +### QuantityCardView attributes |
| 86 | + |
| 87 | +| Attributes | Type | Default | Description |
| 88 | +| ------------------|:--------------:| --------:|------------: |
| 89 | +| android:width | Dimension Pixel | 160dp | Card's width |
| 90 | +| android:height | Dimension Pixel | 55dp | Card's height |
| 91 | +| android:textSize | Dimension | 14sp | Quantity's value size |
| 92 | +| android:textColor | ColorInt | Color.Black | Quantity's value color |
| 93 | +| android:fontFamily | Typeface | Android default | Quantity's value typeface |
| 94 | +| app:startingQuantity | Integer | 0 | Quantity starting value |
| 95 | +| app:minQuantity | Integer | -1999999999 | Quantity minimum value |
| 96 | +| app:maxQuantity | Integer | 1999999999 | Quantity maximum value |
| 97 | +| app:transitionDuration | Integer | 250 | Duration for animation transition |
| 98 | +| app:reverseAnimation | Boolean | false | Animation transition direction |
| 99 | +| app:layoutBackgroundColor | ColorInt | Color.WHITE | Card's background color |
| 100 | +| app:buttonsTextColor | ColorInt | Color.DKGRAY | Increase & Decrease TextView's color |
| 101 | +| app:increaseTextColor | ColorInt | Color.DKGRAY | Increase TextView's color |
| 102 | +| app:decreaseTextColor | ColorInt | Color.DKGRAY | Decrease TextView's color |
| 103 | +| app:buttonsTextSize | Dimension | 13sp | Increase & Decrease TextView's size |
| 104 | +| app:increaseTextSize | Dimension | 13sp | Increase TextView's size |
| 105 | +| app:decreaseTextSize | Dimension | 13sp | Decrease TextView's size |
| 106 | +| app:increaseImageSrc | Reference | null | Image drawable for increase view |
| 107 | +| app:decreaseImageSrc | Reference | null | Image drawable for decrease view |
| 108 | +| app:increaseImageDisabledSrc | Reference | null | Image drawable for increase view when disabled |
| 109 | +| app:decreaseImageDisabledSrc | Reference | null | Image drawable for decrease view when disabled |
| 110 | + |
| 111 | + |
| 112 | + |
0 commit comments