|
1 | 1 | # CheckableTextView |
2 | | -A simple and flexible Checked TextView or Checkable TextView |
| 2 | + |
| 3 | +<a href="https://github.com/JDevZone/CheckableTextView"> |
| 4 | +<img align="left" src="https://github.com/JDevZone/CheckableTextView/blob/master/sample.gif" width="480" height="240" /></a> |
| 5 | + |
| 6 | +<p><h1 align="left">Checkable TextView [KOTLIN]</h1></p> |
| 7 | + |
| 8 | +<h4>A simple and flexible Checked TextView or Checkable TextView written in Kotlin</h4> |
| 9 | + |
| 10 | +___ |
| 11 | + |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +Add it in your root build.gradle at the end of repositories: |
| 16 | + |
| 17 | + allprojects { |
| 18 | + repositories { |
| 19 | + ... |
| 20 | + maven { url 'https://jitpack.io' } |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | +Step 2. Add the dependency in app gradle |
| 25 | + |
| 26 | + dependencies { |
| 27 | + implementation 'com.github.JDevZone:CheckableTextView:1.0.1' |
| 28 | + } |
| 29 | + |
| 30 | +## Basic usage |
| 31 | + |
| 32 | +``` |
| 33 | +<com.devzone.checkabletextview.CheckableTextView |
| 34 | + android:layout_marginTop="20dp" |
| 35 | + android:background="#e8e8e8" |
| 36 | + app:ctv_TextStyle="@style/TextAppearance.General" |
| 37 | + app:ctv_IconTint="@color/colorAccent" |
| 38 | + app:ctv_IconChecked="true" |
| 39 | + app:ctv_Icon="@drawable/ic_cancel_custom_vector" |
| 40 | + app:ctv_Text="@string/app_name" |
| 41 | + android:layout_width="match_parent" |
| 42 | + android:layout_height="wrap_content"/> |
| 43 | +``` |
| 44 | +## Listen State Changes |
| 45 | +You can listen to state changes by registering a listener like as follows : |
| 46 | +``` |
| 47 | +checkedTV.setOnCheckChangeListener() |
| 48 | +``` |
| 49 | +and get callback in implemented method : |
| 50 | +``` |
| 51 | +override fun onCheckChange(view: View, isChecked: Boolean) { |
| 52 | + // checkedTV returned as view |
| 53 | + // isChecked current state of the view |
| 54 | + } |
| 55 | +``` |
| 56 | + |
| 57 | +## Customisation |
| 58 | + |
| 59 | +Here are the attributes you can specify through XML or related setters: |
| 60 | +* `ctv_Text` - Set text. |
| 61 | +* `ctv_TextSize` - Set text size. |
| 62 | +* `ctv_TextColor` - Set text color. |
| 63 | +* `ctv_TextStyle` - Set text style. |
| 64 | +* `ctv_Icon` - Set custom icon. |
| 65 | +* `ctv_IconTint` - Set icon tint. |
| 66 | +* `ctv_IconChecked` - Set textView state checked. |
| 67 | + |
| 68 | +## 📄 License |
| 69 | + |
| 70 | +Checkable TextView is released under the MIT license. |
| 71 | +See [LICENSE](./LICENSE) for details. |
| 72 | + |
| 73 | + |
| 74 | + |
0 commit comments