Animation | Demo |
---|---|
New Ripple Like Fill Effect |
|
Normal |
|
Custom Duration |
Sorry for flicker in slow motion video demo . You know android studio screen recorder sucks sometimes 😅
custom interpolator support added
Interpolator | Demo |
---|---|
BounceInterpolator |
|
AnticipateOvershootInterpolator |
- Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency in app gradle
dependencies {
implementation 'com.github.JDevZone:CheckableTextView:{latest_version}'
}
<com.devzone.checkabletextview.CheckableTextView
app:ctv_TextStyle="@style/TextAppearance.General"
app:ctv_IconTint="@color/colorAccent"
app:ctv_IconChecked="true"
app:ctv_Icon="@drawable/ic_cancel_custom_vector"
app:ctv_Text="@string/app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
You can change checked state as follows :
checkedTV.setChecked(isChecked)
Default value shouldNotifyListeners
is false
or
checkedTV.setChecked(isChecked,shouldNotifyListeners)
First Boolean parameter isChecked
sets the current state
Second Boolean parameter shouldNotifyListeners
determines
if onCheckChange
method should be called or not.
checkedTV.isChecked()
No Fancy enums, Just true for checked state and false for unchecked is returned
You can listen to state changes by registering a listener like as follows :
checkedTV.setOnCheckChangeListener()
and get callback in implemented method :
override fun onCheckChange(view: View, isChecked: Boolean) {
// checkedTV returned as view
// isChecked current state of the view
}
checkedTV.setAnimInterpolator(BounceInterpolator())
checkedTV.setClickEnabled(isClickable: Boolean)
Pass isClickable
true for enable and false for disable clicks
currently restricted to
RestrictTo.Scope.LIBRARY
you can use it simply Suppressing Lint Warnings (if have any) as@SuppressLint("RestrictedApi")
Here are the attributes you can specify through XML or related setters:
ctv_Text
- Set text.ctv_TextSize
- Set text size.ctv_TextColor
- Set text color.ctv_TextStyle
- Set text style.ctv_Icon
- Set custom icon.ctv_IconTint
- Set icon tint.ctv_IconChecked
- Set TextView (CheckableTextView
) state checked.ctv_TextGravity
- Set text gravity.ctv_AnimType
- Set check animation type currently three available (scale
,translate
andfall_down
).ctv_AnimDuration
- Set duration for check animation.ctv_AnimFirstTime
- AnimateCheckableTextView
for very first time.ctv_RippleAlpha
- Set Alpha (Transparency) value for ripple like fill effectctv_RippleTint
- Set color value for ripple like fill effectctv_RippleFillEnabled
- Sets if ripple like fill effect is enabled or not
Checkable TextView is released under the MIT license. See LICENSE for details.