|
| 1 | +# ExpandableTextView |
| 2 | +[](https://jitpack.io/#yuzumone/ExpandableTextView/) |
| 3 | +[](https://www.apache.org/licenses/LICENSE-2.0.html) |
| 4 | + |
| 5 | +ExpandableTextView is an android TextView library that performs multiline ellipsize. |
| 6 | + |
| 7 | +## Demo |
| 8 | + |
| 9 | + |
| 10 | +## Gradle |
| 11 | +### Repository |
| 12 | +Add this to your root `build.gradle` file. |
| 13 | +```gradle |
| 14 | +allprojects { |
| 15 | + repositories { |
| 16 | + ... |
| 17 | + maven { url 'https://jitpack.io' } |
| 18 | + } |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +### Dependency |
| 23 | +Add this to your app `build.gradle` file. |
| 24 | +```gradle |
| 25 | +dependencies { |
| 26 | + ... |
| 27 | + compile 'com.github.yuzumone:ExpandableTextView:0.2.0' |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +## Usage |
| 32 | +### XML |
| 33 | +```xml |
| 34 | +<net.expandable.ExpandableTextView |
| 35 | + android:id="@+id/text" |
| 36 | + android:layout_width="wrap_content" |
| 37 | + android:layout_height="wrap_content" |
| 38 | + /> |
| 39 | +``` |
| 40 | + |
| 41 | +### Attributes |
| 42 | +```xml |
| 43 | +<net.expandable.ExpandableTextView |
| 44 | + app:expand="false" |
| 45 | + app:expand_enabled="true" |
| 46 | + app:collapse_lines="1" |
| 47 | + /> |
| 48 | +``` |
| 49 | + |
| 50 | +## Expand |
| 51 | +To set a state the TextView of ellipsize you use the setExpand functionality via xml or kotlin. Default value is false. |
| 52 | + |
| 53 | +### XML |
| 54 | +```xml |
| 55 | +app:expand="true" |
| 56 | +or |
| 57 | +app:expand="false" |
| 58 | +``` |
| 59 | + |
| 60 | +### Kotlin |
| 61 | +```kotlin |
| 62 | +textView.setExpand(true) |
| 63 | +or |
| 64 | +textView.setExpand(false) |
| 65 | +``` |
| 66 | + |
| 67 | +## Expand_enabled |
| 68 | +To set a state as to whether expand when clicking you use the setExpandEnabled functionality via xml or kotlin. Default value is true. |
| 69 | + |
| 70 | +### XML |
| 71 | +```xml |
| 72 | +app:expand_enabled="true" |
| 73 | +or |
| 74 | +app:expand_enabled="false" |
| 75 | +``` |
| 76 | + |
| 77 | +### Kotlin |
| 78 | +```kotlin |
| 79 | +textView.setExpandEnabled(true) |
| 80 | +or |
| 81 | +textView.setExpandEnabled(false) |
| 82 | +``` |
| 83 | + |
| 84 | +## Collapse_lines |
| 85 | +To set the number of lines when TextView ellipsize you use the setCollapseLines functionality via xml or kotlin. Default value is 1. |
| 86 | + |
| 87 | +### XML |
| 88 | +```xml |
| 89 | +app:collapse_lines="1" |
| 90 | +``` |
| 91 | + |
| 92 | +### Kotlin |
| 93 | +```kotlin |
| 94 | +textView.setCollapseLines(1) |
| 95 | +``` |
| 96 | + |
| 97 | +## OnExpandableClickListener |
| 98 | + |
| 99 | +```kotlin |
| 100 | +textView.setOnExpandableClickListener(object : OnExpandableClickListener { |
| 101 | + override fun expand(view: ExpandableTextView) { |
| 102 | + // Expand action |
| 103 | + } |
| 104 | + |
| 105 | + override fun collapse(view: ExpandableTextView) { |
| 106 | + // Collapse action |
| 107 | + } |
| 108 | +}) |
| 109 | +``` |
| 110 | + |
| 111 | +## License |
| 112 | +``` |
| 113 | +Copyright 2017 yuzumone |
| 114 | +
|
| 115 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 116 | +you may not use this file except in compliance with the License. |
| 117 | +You may obtain a copy of the License at |
| 118 | +
|
| 119 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 120 | +
|
| 121 | +Unless required by applicable law or agreed to in writing, software |
| 122 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 123 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 124 | +See the License for the specific language governing permissions and |
| 125 | +limitations under the License. |
| 126 | +``` |
0 commit comments