├── .gitignore ├── LICENSE ├── README.md ├── art └── readme_demo.gif ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── ms │ │ └── square │ │ └── android │ │ └── expandabletextview │ │ └── ExpandableTextView.java │ └── res │ ├── drawable-hdpi │ ├── ic_expand_less_black_12dp.png │ ├── ic_expand_less_black_16dp.png │ ├── ic_expand_more_black_12dp.png │ └── ic_expand_more_black_16dp.png │ ├── drawable-mdpi │ ├── ic_expand_less_black_12dp.png │ ├── ic_expand_less_black_16dp.png │ ├── ic_expand_more_black_12dp.png │ └── ic_expand_more_black_16dp.png │ ├── drawable-sw600dp │ ├── ic_expand_less.xml │ └── ic_expand_more.xml │ ├── drawable-xhdpi │ ├── ic_expand_less_black_12dp.png │ ├── ic_expand_less_black_16dp.png │ ├── ic_expand_more_black_12dp.png │ └── ic_expand_more_black_16dp.png │ ├── drawable-xxhdpi │ ├── ic_expand_less_black_12dp.png │ ├── ic_expand_less_black_16dp.png │ ├── ic_expand_more_black_12dp.png │ └── ic_expand_more_black_16dp.png │ ├── drawable-xxxhdpi │ ├── ic_expand_less_black_12dp.png │ ├── ic_expand_less_black_16dp.png │ ├── ic_expand_more_black_12dp.png │ └── ic_expand_more_black_16dp.png │ ├── drawable │ ├── ic_expand_less.xml │ └── ic_expand_more.xml │ └── values │ ├── attrs.xml │ └── ids.xml ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── ms │ │ └── square │ │ └── android │ │ └── expandabletextview │ │ └── sample │ │ ├── DemoActivity.java │ │ └── SampleTextListAdapter.java │ └── res │ ├── layout │ ├── activity_demo.xml │ ├── fragment_demo1.xml │ ├── fragment_demo2.xml │ ├── list_item.xml │ └── text_item.xml │ ├── menu │ └── demo.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── arrays.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | local.properties 2 | 3 | # Gradle 4 | .gradle 5 | build/ 6 | 7 | # Android Studio 8 | *.iml 9 | !.idea/runConfigurations/* 10 | .idea/*.xml 11 | .idea/.name 12 | .idea/copyright/ 13 | .idea/libraries/ 14 | .idea/scopes/ 15 | .idea/inspectionProfiles/ 16 | 17 | # Other 18 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2014 Manabu Shimobe 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ExpandableTextView [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ExpandableTextView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1203) 2 | =================== 3 | 4 | ExpandableTextView is an Android library that allows developers to easily create an TextView 5 | which can expand/collapse just like the Google Play's app description. 6 | Feel free to use it all you want in your Android apps provided that you cite this project. 7 | 8 | Quick Demo 9 | 10 | Requirements 11 | ------------- 12 | API Level 8 (Froyo) and above. 13 | 14 | Setup 15 | ------ 16 | The library is pushed to Maven Central as an AAR, 17 | so you just need to add the followings to your ***build.gradle*** file: 18 | 19 | ```groovy 20 | 21 | dependencies { 22 | compile 'com.ms-square:expandableTextView:0.1.4' 23 | } 24 | 25 | ``` 26 | 27 | Usage 28 | ------ 29 | Using the library is really simple, just look at the source code of the [provided sample][1]. 30 | (Look at the SampleTextListAdapter.java for the use within a ListView) 31 | 32 | The important thing to note is that the view Ids for TextView and ImageButton must be set to 33 | "@id/expandable_text" and "@id/expand_collapse" respectively for this library to work. 34 | 35 | Also, you can optionally set the following attributes in your layout xml file to customize the behavior 36 | of the ExpandableTextView. 37 | 38 | * `maxCollapsedLines` (defaults to 8) 39 | The maximum number of text lines allowed to be shown when the TextView gets collapsed 40 | 41 | * `animDuration` (defaults to 300ms) 42 | Duration of the Animation for the expansion/collapse 43 | 44 | * `animAlphaStart` (defaults to 0.7f) 45 | Alpha value of the TextView when the animation starts 46 | (NOTE) 47 | Set this value to 1 if you want to disable the alpha animation. 48 | 49 | * `expandDrawable` 50 | Customize a drawable set to ImageButton to expand the TextView 51 | 52 | * `collapseDrawable` 53 | Customize a drawable set to ImageButton to collapse the TextView 54 | 55 | ```xml 56 | 57 | 65 | 73 | 80 | 81 | ``` 82 | 83 | ```java 84 | // sample code snippet to set the text content on the ExpandableTextView 85 | ExpandableTextView expTv1 = (ExpandableTextView) rootView.findViewById(R.id.sample1) 86 | .findViewById(R.id.expand_text_view); 87 | 88 | // IMPORTANT - call setText on the ExpandableTextView to set the text content to display 89 | expTv1.setText(getString(R.string.dummy_text1)); 90 | ``` 91 | 92 | License 93 | ---------- 94 | 95 | Copyright 2014 Manabu Shimobe 96 | 97 | Licensed under the Apache License, Version 2.0 (the "License"); 98 | you may not use this file except in compliance with the License. 99 | You may obtain a copy of the License at 100 | 101 | http://www.apache.org/licenses/LICENSE-2.0 102 | 103 | Unless required by applicable law or agreed to in writing, software 104 | distributed under the License is distributed on an "AS IS" BASIS, 105 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 106 | See the License for the specific language governing permissions and 107 | limitations under the License. 108 | 109 | [1]: https://github.com/Manabu-GT/ExpandableTextView/tree/master/sample 110 | -------------------------------------------------------------------------------- /art/readme_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/art/readme_demo.gif -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.1.0' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | mavenCentral() 15 | } 16 | } 17 | 18 | // http://www.gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html 19 | project.ext { 20 | ANDROID_COMPILE_SDK_VERSION = 23 21 | ANDROID_BUILD_TOOLS_VERSION = "23.0.3" 22 | 23 | ANDROID_MIN_SDK_VERSION = 8 24 | ANDROID_TARGET_SDK_VERSION = 23 25 | 26 | // Google Stuffs 27 | supportPackageVersion = "23.1.1" 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # For maven central 21 | VERSION_NAME=0.1.4 22 | VERSION_CODE=4 23 | GROUP=com.ms-square 24 | 25 | POM_DESCRIPTION=Android library that allows developers to easily create an TextView which can expand/collapse just like the Google Play's app description. 26 | POM_URL=https://github.com/Manabu-GT/ExpandableTextView 27 | POM_SCM_URL=https://github.com/Manabu-GT/ExpandableTextView 28 | POM_SCM_CONNECTION=scm:git@github.com:Manabu-GT/ExpandableTextView.git 29 | POM_SCM_DEV_CONNECTION=scm:git@github.com:Manabu-GT/ExpandableTextView.git 30 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 31 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 32 | POM_LICENCE_DIST=repo 33 | POM_DEVELOPER_ID=Manabu-GT 34 | POM_DEVELOPER_NAME=Manabu Shimobe -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jun 04 15:13:19 IST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /lib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android-library' 2 | 3 | android { 4 | 5 | compileSdkVersion project.ANDROID_COMPILE_SDK_VERSION 6 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 7 | 8 | defaultConfig { 9 | minSdkVersion project.ANDROID_MIN_SDK_VERSION 10 | targetSdkVersion project.ANDROID_TARGET_SDK_VERSION 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 16 | } 17 | } 18 | } 19 | 20 | dependencies { 21 | compile fileTree(dir: 'libs', include: ['*.jar']) 22 | // to support annotations such as @NonNull 23 | compile "com.android.support:support-annotations:${supportPackageVersion}" 24 | } 25 | 26 | // for maven central deployment 27 | apply from: 'https://raw.githubusercontent.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' -------------------------------------------------------------------------------- /lib/gradle.properties: -------------------------------------------------------------------------------- 1 | # For maven central 2 | POM_NAME=ExpandableTextView Library 3 | POM_ARTIFACT_ID=expandableTextView 4 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /lib/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} -------------------------------------------------------------------------------- /lib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lib/src/main/java/com/ms/square/android/expandabletextview/ExpandableTextView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * Copyright 2014 Manabu Shimobe 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.ms.square.android.expandabletextview; 19 | 20 | import android.annotation.TargetApi; 21 | import android.content.Context; 22 | import android.content.res.Resources; 23 | import android.content.res.TypedArray; 24 | import android.graphics.drawable.Drawable; 25 | import android.os.Build; 26 | import android.support.annotation.DrawableRes; 27 | import android.support.annotation.IdRes; 28 | import android.support.annotation.NonNull; 29 | import android.support.annotation.Nullable; 30 | import android.text.TextUtils; 31 | import android.util.AttributeSet; 32 | import android.util.SparseBooleanArray; 33 | import android.view.MotionEvent; 34 | import android.view.View; 35 | import android.view.ViewGroup; 36 | import android.view.animation.AlphaAnimation; 37 | import android.view.animation.Animation; 38 | import android.view.animation.Transformation; 39 | import android.widget.ImageButton; 40 | import android.widget.LinearLayout; 41 | import android.widget.TextView; 42 | 43 | 44 | public class ExpandableTextView extends LinearLayout implements View.OnClickListener { 45 | 46 | private static final String TAG = ExpandableTextView.class.getSimpleName(); 47 | 48 | private static final int EXPAND_INDICATOR_IMAGE_BUTTON = 0; 49 | 50 | private static final int EXPAND_INDICATOR_TEXT_VIEW = 1; 51 | 52 | private static final int DEFAULT_TOGGLE_TYPE = EXPAND_INDICATOR_IMAGE_BUTTON; 53 | 54 | /* The default number of lines */ 55 | private static final int MAX_COLLAPSED_LINES = 8; 56 | 57 | /* The default animation duration */ 58 | private static final int DEFAULT_ANIM_DURATION = 300; 59 | 60 | /* The default alpha value when the animation starts */ 61 | private static final float DEFAULT_ANIM_ALPHA_START = 0.7f; 62 | 63 | protected TextView mTv; 64 | 65 | protected View mToggleView; // View to expand/collapse 66 | 67 | private boolean mRelayout; 68 | 69 | private boolean mCollapsed = true; // Show short version as default. 70 | 71 | private int mCollapsedHeight; 72 | 73 | private int mTextHeightWithMaxLines; 74 | 75 | private int mMaxCollapsedLines; 76 | 77 | private int mMarginBetweenTxtAndBottom; 78 | 79 | private ExpandIndicatorController mExpandIndicatorController; 80 | 81 | private int mAnimationDuration; 82 | 83 | private float mAnimAlphaStart; 84 | 85 | private boolean mAnimating; 86 | 87 | @IdRes 88 | private int mExpandableTextId = R.id.expandable_text; 89 | 90 | @IdRes 91 | private int mExpandCollapseToggleId = R.id.expand_collapse; 92 | 93 | private boolean mExpandToggleOnTextClick; 94 | 95 | /* Listener for callback */ 96 | private OnExpandStateChangeListener mListener; 97 | 98 | /* For saving collapsed status when used in ListView */ 99 | private SparseBooleanArray mCollapsedStatus; 100 | private int mPosition; 101 | 102 | public ExpandableTextView(Context context) { 103 | this(context, null); 104 | } 105 | 106 | public ExpandableTextView(Context context, AttributeSet attrs) { 107 | super(context, attrs); 108 | init(attrs); 109 | } 110 | 111 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 112 | public ExpandableTextView(Context context, AttributeSet attrs, int defStyle) { 113 | super(context, attrs, defStyle); 114 | init(attrs); 115 | } 116 | 117 | @Override 118 | public void setOrientation(int orientation){ 119 | if(LinearLayout.HORIZONTAL == orientation){ 120 | throw new IllegalArgumentException("ExpandableTextView only supports Vertical Orientation."); 121 | } 122 | super.setOrientation(orientation); 123 | } 124 | 125 | @Override 126 | public void onClick(View view) { 127 | if (mToggleView.getVisibility() != View.VISIBLE) { 128 | return; 129 | } 130 | 131 | mCollapsed = !mCollapsed; 132 | mExpandIndicatorController.changeState(mCollapsed); 133 | 134 | if (mCollapsedStatus != null) { 135 | mCollapsedStatus.put(mPosition, mCollapsed); 136 | } 137 | 138 | // mark that the animation is in progress 139 | mAnimating = true; 140 | 141 | Animation animation; 142 | if (mCollapsed) { 143 | animation = new ExpandCollapseAnimation(this, getHeight(), mCollapsedHeight); 144 | } else { 145 | animation = new ExpandCollapseAnimation(this, getHeight(), getHeight() + 146 | mTextHeightWithMaxLines - mTv.getHeight()); 147 | } 148 | 149 | animation.setFillAfter(true); 150 | animation.setAnimationListener(new Animation.AnimationListener() { 151 | @Override 152 | public void onAnimationStart(Animation animation) { 153 | applyAlphaAnimation(mTv, mAnimAlphaStart); 154 | } 155 | @Override 156 | public void onAnimationEnd(Animation animation) { 157 | // clear animation here to avoid repeated applyTransformation() calls 158 | clearAnimation(); 159 | // clear the animation flag 160 | mAnimating = false; 161 | 162 | // notify the listener 163 | if (mListener != null) { 164 | mListener.onExpandStateChanged(mTv, !mCollapsed); 165 | } 166 | } 167 | @Override 168 | public void onAnimationRepeat(Animation animation) { } 169 | }); 170 | 171 | clearAnimation(); 172 | startAnimation(animation); 173 | } 174 | 175 | @Override 176 | public boolean onInterceptTouchEvent(MotionEvent ev) { 177 | // while an animation is in progress, intercept all the touch events to children to 178 | // prevent extra clicks during the animation 179 | return mAnimating; 180 | } 181 | 182 | @Override 183 | protected void onFinishInflate() { 184 | super.onFinishInflate(); 185 | findViews(); 186 | } 187 | 188 | @Override 189 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 190 | // If no change, measure and return 191 | if (!mRelayout || getVisibility() == View.GONE) { 192 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 193 | return; 194 | } 195 | mRelayout = false; 196 | 197 | // Setup with optimistic case 198 | // i.e. Everything fits. No button needed 199 | mToggleView.setVisibility(View.GONE); 200 | mTv.setMaxLines(Integer.MAX_VALUE); 201 | 202 | // Measure 203 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 204 | 205 | // If the text fits in collapsed mode, we are done. 206 | if (mTv.getLineCount() <= mMaxCollapsedLines) { 207 | return; 208 | } 209 | 210 | // Saves the text height w/ max lines 211 | mTextHeightWithMaxLines = getRealTextViewHeight(mTv); 212 | 213 | // Doesn't fit in collapsed mode. Collapse text view as needed. Show 214 | // button. 215 | if (mCollapsed) { 216 | mTv.setMaxLines(mMaxCollapsedLines); 217 | } 218 | mToggleView.setVisibility(View.VISIBLE); 219 | 220 | // Re-measure with new setup 221 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 222 | 223 | if (mCollapsed) { 224 | // Gets the margin between the TextView's bottom and the ViewGroup's bottom 225 | mTv.post(new Runnable() { 226 | @Override 227 | public void run() { 228 | mMarginBetweenTxtAndBottom = getHeight() - mTv.getHeight(); 229 | } 230 | }); 231 | // Saves the collapsed height of this ViewGroup 232 | mCollapsedHeight = getMeasuredHeight(); 233 | } 234 | } 235 | 236 | public void setOnExpandStateChangeListener(@Nullable OnExpandStateChangeListener listener) { 237 | mListener = listener; 238 | } 239 | 240 | public void setText(@Nullable CharSequence text) { 241 | mRelayout = true; 242 | mTv.setText(text); 243 | setVisibility(TextUtils.isEmpty(text) ? View.GONE : View.VISIBLE); 244 | clearAnimation(); 245 | getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; 246 | requestLayout(); 247 | } 248 | 249 | public void setText(@Nullable CharSequence text, @NonNull SparseBooleanArray collapsedStatus, int position) { 250 | mCollapsedStatus = collapsedStatus; 251 | mPosition = position; 252 | boolean isCollapsed = collapsedStatus.get(position, true); 253 | clearAnimation(); 254 | mCollapsed = isCollapsed; 255 | mExpandIndicatorController.changeState(mCollapsed); 256 | setText(text); 257 | } 258 | 259 | @Nullable 260 | public CharSequence getText() { 261 | if (mTv == null) { 262 | return ""; 263 | } 264 | return mTv.getText(); 265 | } 266 | 267 | private void init(AttributeSet attrs) { 268 | TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView); 269 | mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines, MAX_COLLAPSED_LINES); 270 | mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION); 271 | mAnimAlphaStart = typedArray.getFloat(R.styleable.ExpandableTextView_animAlphaStart, DEFAULT_ANIM_ALPHA_START); 272 | mExpandableTextId = typedArray.getResourceId(R.styleable.ExpandableTextView_expandableTextId, R.id.expandable_text); 273 | mExpandCollapseToggleId = typedArray.getResourceId(R.styleable.ExpandableTextView_expandCollapseToggleId, R.id.expand_collapse); 274 | mExpandToggleOnTextClick = typedArray.getBoolean(R.styleable.ExpandableTextView_expandToggleOnTextClick, true); 275 | 276 | mExpandIndicatorController = setupExpandToggleController(getContext(), typedArray); 277 | 278 | typedArray.recycle(); 279 | 280 | // enforces vertical orientation 281 | setOrientation(LinearLayout.VERTICAL); 282 | 283 | // default visibility is gone 284 | setVisibility(GONE); 285 | } 286 | 287 | private void findViews() { 288 | mTv = (TextView) findViewById(mExpandableTextId); 289 | if (mExpandToggleOnTextClick) { 290 | mTv.setOnClickListener(this); 291 | } else { 292 | mTv.setOnClickListener(null); 293 | } 294 | mToggleView = findViewById(mExpandCollapseToggleId); 295 | mExpandIndicatorController.setView(mToggleView); 296 | mExpandIndicatorController.changeState(mCollapsed); 297 | mToggleView.setOnClickListener(this); 298 | } 299 | 300 | private static boolean isPostHoneycomb() { 301 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; 302 | } 303 | 304 | private static boolean isPostLolipop() { 305 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; 306 | } 307 | 308 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 309 | private static void applyAlphaAnimation(View view, float alpha) { 310 | if (isPostHoneycomb()) { 311 | view.setAlpha(alpha); 312 | } else { 313 | AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha); 314 | // make it instant 315 | alphaAnimation.setDuration(0); 316 | alphaAnimation.setFillAfter(true); 317 | view.startAnimation(alphaAnimation); 318 | } 319 | } 320 | 321 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 322 | private static Drawable getDrawable(@NonNull Context context, @DrawableRes int resId) { 323 | Resources resources = context.getResources(); 324 | if (isPostLolipop()) { 325 | return resources.getDrawable(resId, context.getTheme()); 326 | } else { 327 | return resources.getDrawable(resId); 328 | } 329 | } 330 | 331 | private static int getRealTextViewHeight(@NonNull TextView textView) { 332 | int textHeight = textView.getLayout().getLineTop(textView.getLineCount()); 333 | int padding = textView.getCompoundPaddingTop() + textView.getCompoundPaddingBottom(); 334 | return textHeight + padding; 335 | } 336 | 337 | private static ExpandIndicatorController setupExpandToggleController(@NonNull Context context, TypedArray typedArray) { 338 | final int expandToggleType = typedArray.getInt(R.styleable.ExpandableTextView_expandToggleType, DEFAULT_TOGGLE_TYPE); 339 | final ExpandIndicatorController expandIndicatorController; 340 | switch (expandToggleType) { 341 | case EXPAND_INDICATOR_IMAGE_BUTTON: 342 | Drawable expandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandIndicator); 343 | Drawable collapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseIndicator); 344 | 345 | if (expandDrawable == null) { 346 | expandDrawable = getDrawable(context, R.drawable.ic_expand_more_black_12dp); 347 | } 348 | if (collapseDrawable == null) { 349 | collapseDrawable = getDrawable(context, R.drawable.ic_expand_less_black_12dp); 350 | } 351 | expandIndicatorController = new ImageButtonExpandController(expandDrawable, collapseDrawable); 352 | break; 353 | case EXPAND_INDICATOR_TEXT_VIEW: 354 | String expandText = typedArray.getString(R.styleable.ExpandableTextView_expandIndicator); 355 | String collapseText = typedArray.getString(R.styleable.ExpandableTextView_collapseIndicator); 356 | expandIndicatorController = new TextViewExpandController(expandText, collapseText); 357 | break; 358 | default: 359 | throw new IllegalStateException("Must be of enum: ExpandableTextView_expandToggleType, one of EXPAND_INDICATOR_IMAGE_BUTTON or EXPAND_INDICATOR_TEXT_VIEW."); 360 | } 361 | 362 | return expandIndicatorController; 363 | } 364 | 365 | class ExpandCollapseAnimation extends Animation { 366 | private final View mTargetView; 367 | private final int mStartHeight; 368 | private final int mEndHeight; 369 | 370 | public ExpandCollapseAnimation(View view, int startHeight, int endHeight) { 371 | mTargetView = view; 372 | mStartHeight = startHeight; 373 | mEndHeight = endHeight; 374 | setDuration(mAnimationDuration); 375 | } 376 | 377 | @Override 378 | protected void applyTransformation(float interpolatedTime, Transformation t) { 379 | final int newHeight = (int)((mEndHeight - mStartHeight) * interpolatedTime + mStartHeight); 380 | mTv.setMaxHeight(newHeight - mMarginBetweenTxtAndBottom); 381 | if (Float.compare(mAnimAlphaStart, 1.0f) != 0) { 382 | applyAlphaAnimation(mTv, mAnimAlphaStart + interpolatedTime * (1.0f - mAnimAlphaStart)); 383 | } 384 | mTargetView.getLayoutParams().height = newHeight; 385 | mTargetView.requestLayout(); 386 | } 387 | 388 | @Override 389 | public void initialize( int width, int height, int parentWidth, int parentHeight ) { 390 | super.initialize(width, height, parentWidth, parentHeight); 391 | } 392 | 393 | @Override 394 | public boolean willChangeBounds( ) { 395 | return true; 396 | } 397 | } 398 | 399 | public interface OnExpandStateChangeListener { 400 | /** 401 | * Called when the expand/collapse animation has been finished 402 | * 403 | * @param textView - TextView being expanded/collapsed 404 | * @param isExpanded - true if the TextView has been expanded 405 | */ 406 | void onExpandStateChanged(TextView textView, boolean isExpanded); 407 | } 408 | 409 | interface ExpandIndicatorController { 410 | void changeState(boolean collapsed); 411 | 412 | void setView(View toggleView); 413 | } 414 | 415 | static class ImageButtonExpandController implements ExpandIndicatorController { 416 | 417 | private final Drawable mExpandDrawable; 418 | private final Drawable mCollapseDrawable; 419 | 420 | private ImageButton mImageButton; 421 | 422 | public ImageButtonExpandController(Drawable expandDrawable, Drawable collapseDrawable) { 423 | mExpandDrawable = expandDrawable; 424 | mCollapseDrawable = collapseDrawable; 425 | } 426 | 427 | @Override 428 | public void changeState(boolean collapsed) { 429 | mImageButton.setImageDrawable(collapsed ? mExpandDrawable : mCollapseDrawable); 430 | } 431 | 432 | @Override 433 | public void setView(View toggleView) { 434 | mImageButton = (ImageButton) toggleView; 435 | } 436 | } 437 | 438 | static class TextViewExpandController implements ExpandIndicatorController { 439 | 440 | private final String mExpandText; 441 | private final String mCollapseText; 442 | 443 | private TextView mTextView; 444 | 445 | public TextViewExpandController(String expandText, String collapseText) { 446 | mExpandText = expandText; 447 | mCollapseText = collapseText; 448 | } 449 | 450 | @Override 451 | public void changeState(boolean collapsed) { 452 | mTextView.setText(collapsed ? mExpandText : mCollapseText); 453 | } 454 | 455 | @Override 456 | public void setView(View toggleView) { 457 | mTextView = (TextView) toggleView; 458 | } 459 | } 460 | } -------------------------------------------------------------------------------- /lib/src/main/res/drawable-hdpi/ic_expand_less_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-hdpi/ic_expand_less_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-hdpi/ic_expand_less_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-hdpi/ic_expand_less_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-hdpi/ic_expand_more_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-hdpi/ic_expand_more_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-hdpi/ic_expand_more_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-hdpi/ic_expand_more_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-mdpi/ic_expand_less_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-mdpi/ic_expand_less_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-mdpi/ic_expand_less_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-mdpi/ic_expand_less_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-mdpi/ic_expand_more_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-mdpi/ic_expand_more_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-mdpi/ic_expand_more_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-mdpi/ic_expand_more_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-sw600dp/ic_expand_less.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 20 | 21 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable-sw600dp/ic_expand_more.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 20 | 21 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xhdpi/ic_expand_less_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xhdpi/ic_expand_less_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xhdpi/ic_expand_less_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xhdpi/ic_expand_less_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xhdpi/ic_expand_more_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xhdpi/ic_expand_more_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xhdpi/ic_expand_more_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xhdpi/ic_expand_more_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xxhdpi/ic_expand_less_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xxhdpi/ic_expand_less_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xxhdpi/ic_expand_less_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xxhdpi/ic_expand_less_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xxhdpi/ic_expand_more_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xxhdpi/ic_expand_more_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xxhdpi/ic_expand_more_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xxhdpi/ic_expand_more_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xxxhdpi/ic_expand_less_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xxxhdpi/ic_expand_less_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xxxhdpi/ic_expand_less_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xxxhdpi/ic_expand_less_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xxxhdpi/ic_expand_more_black_12dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xxxhdpi/ic_expand_more_black_12dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable-xxxhdpi/ic_expand_more_black_16dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/lib/src/main/res/drawable-xxxhdpi/ic_expand_more_black_16dp.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable/ic_expand_less.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 16 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/ic_expand_more.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 16 | -------------------------------------------------------------------------------- /lib/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /lib/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | android { 4 | 5 | compileSdkVersion project.ANDROID_COMPILE_SDK_VERSION 6 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 7 | 8 | defaultConfig { 9 | minSdkVersion project.ANDROID_MIN_SDK_VERSION 10 | targetSdkVersion project.ANDROID_TARGET_SDK_VERSION 11 | versionCode 1 12 | versionName "1.0.0" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | compile project(':lib') 26 | compile "com.android.support:appcompat-v7:${supportPackageVersion}" 27 | compile "com.android.support:design:${supportPackageVersion}" 28 | } 29 | -------------------------------------------------------------------------------- /sample/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sample/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/sample/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /sample/src/main/java/com/ms/square/android/expandabletextview/sample/DemoActivity.java: -------------------------------------------------------------------------------- 1 | package com.ms.square.android.expandabletextview.sample; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.TabLayout; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentManager; 7 | import android.support.v4.app.FragmentPagerAdapter; 8 | import android.support.v4.app.ListFragment; 9 | import android.support.v4.view.ViewPager; 10 | import android.support.v7.app.AppCompatActivity; 11 | import android.view.LayoutInflater; 12 | import android.view.Menu; 13 | import android.view.MenuItem; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | import android.widget.TextView; 17 | import android.widget.Toast; 18 | 19 | import com.ms.square.android.expandabletextview.ExpandableTextView; 20 | import com.ms.square.android.mymodule.app.R; 21 | 22 | /** 23 | * Demo Activity which demos the features of the ExpandableTextView. 24 | * 25 | * @author Manabu-GT 26 | */ 27 | public class DemoActivity extends AppCompatActivity { 28 | 29 | private static final String POSITION = "POSITION"; 30 | 31 | /** 32 | * The {@link android.support.v4.view.PagerAdapter} that will provide 33 | * fragments for each of the sections. We use a 34 | * {@link FragmentPagerAdapter} derivative, which will keep every 35 | * loaded fragment in memory. If this becomes too memory intensive, it 36 | * may be best to switch to a 37 | * {@link android.support.v4.app.FragmentStatePagerAdapter}. 38 | */ 39 | private SectionsPagerAdapter mSectionsPagerAdapter; 40 | 41 | /** 42 | * The {@link ViewPager} that will host the section contents. 43 | */ 44 | private ViewPager mViewPager; 45 | 46 | private TabLayout mTabLayout; 47 | 48 | @Override 49 | protected void onCreate(Bundle savedInstanceState) { 50 | super.onCreate(savedInstanceState); 51 | setContentView(R.layout.activity_demo); 52 | 53 | // Create the adapter that will return a fragment for each of the three 54 | // primary sections of the activity. 55 | mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); 56 | 57 | // Set up the ViewPager with the sections adapter. 58 | mViewPager = (ViewPager) findViewById(R.id.container); 59 | mViewPager.setAdapter(mSectionsPagerAdapter); 60 | 61 | mTabLayout = (TabLayout) findViewById(R.id.tabs); 62 | mTabLayout.setupWithViewPager(mViewPager); 63 | setupTabLayout(mTabLayout); 64 | } 65 | 66 | 67 | @Override 68 | public boolean onCreateOptionsMenu(Menu menu) { 69 | // Inflate the menu; this adds items to the action bar if it is present. 70 | getMenuInflater().inflate(R.menu.demo, menu); 71 | return true; 72 | } 73 | 74 | @Override 75 | public boolean onOptionsItemSelected(MenuItem item) { 76 | // Handle action bar item clicks here. The action bar will 77 | // automatically handle clicks on the Home/Up button, so long 78 | // as you specify a parent activity in AndroidManifest.xml. 79 | int id = item.getItemId(); 80 | if (id == R.id.action_settings) { 81 | return true; 82 | } 83 | return super.onOptionsItemSelected(item); 84 | } 85 | 86 | private void setupTabLayout(TabLayout tabLayout) { 87 | tabLayout.setTabMode(TabLayout.MODE_FIXED); 88 | tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); 89 | tabLayout.setupWithViewPager(mViewPager); 90 | } 91 | 92 | @Override 93 | public void onSaveInstanceState(Bundle outState) { 94 | super.onSaveInstanceState(outState); 95 | outState.putInt(POSITION, mTabLayout.getSelectedTabPosition()); 96 | } 97 | 98 | @Override 99 | protected void onRestoreInstanceState(Bundle savedInstanceState) { 100 | super.onRestoreInstanceState(savedInstanceState); 101 | mViewPager.setCurrentItem(savedInstanceState.getInt(POSITION)); 102 | } 103 | 104 | /** 105 | * A {@link FragmentPagerAdapter} that returns a fragment corresponding to 106 | * one of the sections/tabs/pages. 107 | */ 108 | class SectionsPagerAdapter extends FragmentPagerAdapter { 109 | 110 | public SectionsPagerAdapter(FragmentManager fm) { 111 | super(fm); 112 | } 113 | 114 | @Override 115 | public Fragment getItem(int position) { 116 | if (position == 0) { 117 | return new Demo1Fragment(); 118 | } else { 119 | return new Demo2Fragment(); 120 | } 121 | } 122 | 123 | @Override 124 | public int getCount() { 125 | return 2; 126 | } 127 | 128 | @Override 129 | public CharSequence getPageTitle(int position) { 130 | switch (position) { 131 | case 0: 132 | return getString(R.string.title_demo1); 133 | case 1: 134 | return getString(R.string.title_demo2); 135 | } 136 | return null; 137 | } 138 | } 139 | 140 | public static class Demo1Fragment extends Fragment { 141 | @Override 142 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 143 | Bundle savedInstanceState) { 144 | View rootView = inflater.inflate(R.layout.fragment_demo1, container, false); 145 | 146 | ((TextView) rootView.findViewById(R.id.sample1).findViewById(R.id.title)).setText("Sample 1"); 147 | ((TextView) rootView.findViewById(R.id.sample2).findViewById(R.id.title)).setText("Sample 2"); 148 | 149 | ExpandableTextView expTv1 = (ExpandableTextView) rootView.findViewById(R.id.sample1) 150 | .findViewById(R.id.expand_text_view); 151 | ExpandableTextView expTv2 = (ExpandableTextView) rootView.findViewById(R.id.sample2) 152 | .findViewById(R.id.expand_text_view); 153 | 154 | expTv1.setOnExpandStateChangeListener(new ExpandableTextView.OnExpandStateChangeListener() { 155 | @Override 156 | public void onExpandStateChanged(TextView textView, boolean isExpanded) { 157 | Toast.makeText(getActivity(), isExpanded ? "Expanded" : "Collapsed", Toast.LENGTH_SHORT).show(); 158 | } 159 | }); 160 | 161 | expTv1.setText(getString(R.string.dummy_text1)); 162 | expTv2.setText(getString(R.string.dummy_text2)); 163 | 164 | return rootView; 165 | } 166 | } 167 | 168 | public static class Demo2Fragment extends ListFragment { 169 | @Override 170 | public void onViewCreated(View view, Bundle savedInstanceState) { 171 | super.onViewCreated(view, savedInstanceState); 172 | SampleTextListAdapter adapter = new SampleTextListAdapter(getActivity()); 173 | setListAdapter(adapter); 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /sample/src/main/java/com/ms/square/android/expandabletextview/sample/SampleTextListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ms.square.android.expandabletextview.sample; 2 | 3 | import android.content.Context; 4 | import android.util.SparseBooleanArray; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.BaseAdapter; 9 | 10 | import com.ms.square.android.expandabletextview.ExpandableTextView; 11 | import com.ms.square.android.mymodule.app.R; 12 | 13 | public class SampleTextListAdapter extends BaseAdapter { 14 | 15 | private final Context mContext; 16 | private final SparseBooleanArray mCollapsedStatus; 17 | private final String[] sampleStrings; 18 | 19 | public SampleTextListAdapter(Context context) { 20 | mContext = context; 21 | mCollapsedStatus = new SparseBooleanArray(); 22 | sampleStrings = mContext.getResources().getStringArray(R.array.sampleStrings); 23 | } 24 | 25 | @Override 26 | public int getCount() { 27 | return sampleStrings.length; 28 | } 29 | 30 | @Override 31 | public Object getItem(int position) { 32 | return null; 33 | } 34 | 35 | @Override 36 | public long getItemId(int position) { 37 | return 0; 38 | } 39 | 40 | @Override 41 | public View getView(int position, View convertView, ViewGroup parent) { 42 | final ViewHolder viewHolder; 43 | if (convertView == null) { 44 | convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item, parent, false); 45 | viewHolder = new ViewHolder(); 46 | viewHolder.expandableTextView = (ExpandableTextView) convertView.findViewById(R.id.expand_text_view); 47 | convertView.setTag(viewHolder); 48 | } else { 49 | viewHolder = (ViewHolder) convertView.getTag(); 50 | } 51 | 52 | viewHolder.expandableTextView.setText(sampleStrings[position], mCollapsedStatus, position); 53 | 54 | return convertView; 55 | } 56 | 57 | 58 | private static class ViewHolder{ 59 | ExpandableTextView expandableTextView; 60 | } 61 | } -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/fragment_demo1.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 17 | 18 | 21 | 22 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/fragment_demo2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 25 | 26 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/text_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 18 | 19 | 24 | 25 | 35 | 36 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/demo.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Manabu-GT/ExpandableTextView/b3b81486bc45d2e94440d6d4395b2030b8a83996/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | "Android provides a rich application framework that allows you to build innovative apps and games for mobile devices in a Java language environment. The documents listed in the left navigation provide details about how to build apps using Android's various APIs." 5 | "Android apps are built as a combination of distinct components that can be invoked individually. For instance, an individual activity provides a single screen for a user interface, and a service independently performs work in the background." 6 | "From one component you can start another component using an intent. You can even start a component in a different app, such an activity in a maps app to show an address. This model provides multiple entry points for a single app and allows any app to behave as a user's "default" for an action that other apps may invoke." 7 | "You can query the availability of device features at runtime if any app features require specific hardware such as a camera. If necessary, you can also declare features your app requires so app markets such as Google Play Store do not allow installation on devices that do not support that feature." 8 | "Android provides an adaptive app framework that allows you to provide unique resources for different device configurations. For example, you can create different XML layout files for different screen sizes and the system determines which layout to apply based on the current device's screen size." 9 | "Android provides a rich application framework that allows you to build innovative apps and games for mobile devices in a Java language environment. The documents listed in the left navigation provide details about how to build apps using Android's various APIs." 10 | "Android provides a rich application framework that allows you to build innovative apps and games for mobile devices in a Java language environment. The documents listed in the left navigation provide details about how to build apps using Android's various APIs." 11 | "Android provides a rich application framework that allows you to build innovative apps and games for mobile devices in a Java language environment. The documents listed in the left navigation provide details about how to build apps using Android's various APIs." 12 | "Android provides a rich application framework that allows you to build innovative apps and games for mobile devices in a Java language environment. The documents listed in the left navigation provide details about how to build apps using Android's various APIs." 13 | "Android provides a rich application framework that allows you to build innovative apps and games for mobile devices in a Java language environment. The documents listed in the left navigation provide details about how to build apps using Android's various APIs." 14 | "test" 15 | 16 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 8dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ExpandableTextView Demo 5 | Settings 6 | Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. 7 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt.\\n\\nCras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. 8 | Demo 9 | In ScrollView 10 | In ListView 11 | 12 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':lib', 'sample' 2 | --------------------------------------------------------------------------------