✨ A highly customizable quantity stepper for android projects
Add it in your root build.gradle
at the end of repositories:
allprojects {
repositories {
//...omitted for brevity
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation "com.github.kojofosu:Quantitizer:$latest_release"
}
Sample implementation here
- Add
HorizontalQuantitizer
in your layout xml file
<com.mcdev.quantitizerlibrary.HorizontalQuantitizer
android:id="@+id/h_q"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
- Add
VerticalQuantitizer
in your layout xml file
<com.mcdev.quantitizerlibrary.VerticalQuantitizer
android:id="@+id/v_q"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
- Add
NoValueQuantitizer
in your layout xml file
<com.mcdev.quantitizerlibrary.NoValueQuantitizer
android:id="@+id/n_q"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
var hQ: HorizontalQuantitizer = findViewById(R.id.h_q)
var selectedValue = hQ.value //get current value
hQ.setQuantitizerListener(object: QuantitizerListener{
override fun onIncrease() {
Toast.makeText(this@MainActivity, "inc", Toast.LENGTH_SHORT).show()
}
override fun onDecrease() {
Toast.makeText(this@MainActivity, "dec", Toast.LENGTH_SHORT).show()
}
override fun onValueChanged(value: Int) {
Toast.makeText(this@ButtonsOnlyActivity, "value changed to : $value", Toast.LENGTH_SHORT).show()
}
})
hQ.textAnimationStyle = AnimationStyle.SLIDE_IN
ANIMATION | DEMO |
---|---|
FALL_IN |
|
SLIDE_IN |
|
SLIDE_IN_REVERSE |
|
SWING |
hQ.isReadOnly = false // Disable value input from keyboard. Default false
hQ.buttonAnimationEnabled = false //Default true
hQ.animationDuration = 400L //Default 300L
hQ.setPlusIcon(R.drawable.ic_angle_double_small_right)
hQ.setMinusIcon(R.drawable.ic_angle_double_small_left)
hQ.setPlusIconBackgroundColor(android.R.color.holo_red_dark)
hQ.setMinusIconBackgroundColor(android.R.color.holo_red_dark)
hQ.setValueBackgroundColor(android.R.color.holo_red_dark)
hQ.setValueTextColor("#FFFF00")
hQ.setMinusIconColor("#FFFF00")
hQ.setPlusIconColor("#FFFF00")
changeShapeAndColorDecrease(Color.parseColor("#FF4500"), R.drawable.heart_shape)
changeShapeAndColorIncrease(Color.parseColor("#1E90FF"), R.drawable.shape_x)
using these mthods inside the required component you will be able to change and customize the shape of the button according to you use
hq.apply {}
for horizontal
changeTextSizeHorizontal(10f)
for vertical
changeTextSizeVertical(50f)
Licensed under the MIT License
MIT License
Copyright (c) 2021 Kojo Fosu Bempa Edue
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.