Skip to content

Commit 320d85a

Browse files
committed
Merge branch 'release/1.0.0'
2 parents a5256b4 + 14d6832 commit 320d85a

File tree

36 files changed

+646
-252
lines changed

36 files changed

+646
-252
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ proguard/
3030

3131
# Android Studio captures folder
3232
captures/
33+
34+
*.iml

Android-ExpandableTextView.iml

-19
This file was deleted.

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CHANGE LOG
2+
==========================
3+
4+
1.0.0
5+
-----
6+
Initial version of the ExpandableTextView

ExpandableTextView.iml

-19
This file was deleted.

README.md

+144-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,144 @@
1-
# Android-ExpandableTextView
2-
An expandable TextView for Android applications
1+
Android-ExpandableTextView
2+
==========================
3+
An expandable TextView for Android applications (4.0+).
4+
5+
[ ![Download](https://api.bintray.com/packages/blogcat/maven/android-expandabletextview/images/download.svg) ](https://bintray.com/blogcat/maven/android-expandabletextview/_latestVersion)
6+
7+
Demo
8+
----
9+
This repository also contains a demo project.
10+
11+
![Demo](https://raw.githubusercontent.com/Blogcat/Android-ExpandableTextView/release/1.0.0/demo.gif)
12+
13+
Add dependency
14+
--------------
15+
This library is not yet released in Maven Central, but instead you can use [Bintray](https://www.bintray.com).
16+
17+
```groovy
18+
repositories {
19+
maven {
20+
url "https://dl.bintray.com/blogcat/maven"
21+
}
22+
}
23+
```
24+
25+
library dependency
26+
27+
```groovy
28+
dependencies {
29+
compile ('at.blogc:expandabletextview:1.0.0@aar')
30+
}
31+
```
32+
33+
Usage
34+
-----
35+
Using the ExpandableTextView is very easy, it's just a regular TextView with some extra functionality added to it. By defining the android:maxLines attribute, you can set the default number of lines for the TextView collapsed state.
36+
37+
```xml
38+
<LinearLayout
39+
xmlns:android="http://schemas.android.com/apk/res/android"
40+
xmlns:app="http://schemas.android.com/apk/res-auto"
41+
android:layout_width="match_parent"
42+
android:layout_height="match_parent"
43+
android:orientation="vertical">
44+
45+
<at.blogc.android.views.ExpandableTextView
46+
android:id="@+id/expandableTextView"
47+
android:layout_width="wrap_content"
48+
android:layout_height="wrap_content"
49+
android:text="@string/lorem_ipsum"
50+
android:maxLines="5"
51+
android:ellipsize="end"
52+
app:animation_duration="1000"/>
53+
54+
<!-- Optional parameter animation_duration: sets the duration of the expand animation -->
55+
56+
<Button
57+
android:id="@+id/button_toggle"
58+
android:layout_width="wrap_content"
59+
android:layout_height="wrap_content"
60+
android:text="@string/expand"/>
61+
62+
</LinearLayout>
63+
```
64+
65+
In your Activity or Fragment:
66+
67+
```java
68+
final ExpandableTextView expandableTextView = (ExpandableTextView) this.findViewById(R.id.expandableTextView);
69+
final Button buttonToggle = (Button) this.findViewById(R.id.button_toggle);
70+
71+
// set animation duration via code, but preferable in your layout files by using the animation_duration attribute
72+
expandableTextView.setAnimationDuration(1000L);
73+
74+
// toggle the ExpandableTextView
75+
buttonToggle.setOnClickListener(new View.OnClickListener()
76+
{
77+
@Override
78+
public void onClick(final View v)
79+
{
80+
expandableTextView.toggle();
81+
buttonToggle.setText(expandableTextView.isExpanded() ? R.string.collapse : R.string.expand);
82+
}
83+
});
84+
85+
// but, you can also do the checks yourself
86+
buttonToggle.setOnClickListener(new View.OnClickListener()
87+
{
88+
@Override
89+
public void onClick(final View v)
90+
{
91+
if (expandableTextView.isExpanded())
92+
{
93+
expandableTextView.collapse();
94+
buttonToggle.setText(R.string.expand);
95+
}
96+
else
97+
{
98+
expandableTextView.expand();
99+
buttonToggle.setText(R.string.collapse);
100+
}
101+
}
102+
});
103+
104+
// listen for expand / collapse events
105+
expandableTextView.setOnExpandListener(new ExpandableTextView.OnExpandListener()
106+
{
107+
@Override
108+
public void onExpand(final ExpandableTextView view)
109+
{
110+
Log.d(TAG, "ExpandableTextView expanded");
111+
}
112+
113+
@Override
114+
public void onCollapse(final ExpandableTextView view)
115+
{
116+
Log.d(TAG, "ExpandableTextView collapsed");
117+
}
118+
});
119+
```
120+
121+
Roadmap
122+
=======
123+
124+
* take into account TextView padding and margin
125+
* optional fading edge at the bottom of the TextView
126+
* support for Interpolators
127+
* update demo project with more examples
128+
129+
License
130+
=======
131+
132+
Copyright 2016 Cliff Ophalvens (Blogc.at)
133+
134+
Licensed under the Apache License, Version 2.0 (the "License");
135+
you may not use this file except in compliance with the License.
136+
You may obtain a copy of the License at
137+
138+
http://www.apache.org/licenses/LICENSE-2.0
139+
140+
Unless required by applicable law or agreed to in writing, software
141+
distributed under the License is distributed on an "AS IS" BASIS,
142+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
143+
See the License for the specific language governing permissions and
144+
limitations under the License.

app/app.iml

-108
This file was deleted.

app/build.gradle

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ android {
2121

2222
dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
testCompile 'junit:junit:4.12'
2524
compile 'com.android.support:appcompat-v7:23.1.1'
25+
compile project(':expandabletextview')
26+
27+
28+
testCompile 'junit:junit:4.12'
2629
}

app/src/androidTest/java/blogc/at/android/views/ApplicationTest.java renamed to app/src/androidTest/java/at/blogc/android/views/ApplicationTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package blogc.at.android.views;
1+
package at.blogc.android.views;
22

33
import android.app.Application;
44
import android.test.ApplicationTestCase;

app/src/main/AndroidManifest.xml

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest package="blogc.at.android.views"
2+
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<manifest package="at.blogc.android.views"
317
xmlns:android="http://schemas.android.com/apk/res/android">
418

519
<application
@@ -8,7 +22,7 @@
822
android:label="@string/app_name"
923
android:supportsRtl="true"
1024
android:theme="@style/AppTheme">
11-
<activity android:name="blogc.at.android.activities.MainActivity">
25+
<activity android:name="at.blogc.android.activities.MainActivity">
1226
<intent-filter>
1327
<action android:name="android.intent.action.MAIN"/>
1428

0 commit comments

Comments
 (0)