Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Cliffus committed Feb 27, 2016
2 parents a5256b4 + 14d6832 commit 320d85a
Show file tree
Hide file tree
Showing 36 changed files with 646 additions and 252 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ proguard/

# Android Studio captures folder
captures/

*.iml
19 changes: 0 additions & 19 deletions Android-ExpandableTextView.iml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CHANGE LOG
==========================

1.0.0
-----
Initial version of the ExpandableTextView
19 changes: 0 additions & 19 deletions ExpandableTextView.iml

This file was deleted.

146 changes: 144 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,144 @@
# Android-ExpandableTextView
An expandable TextView for Android applications
Android-ExpandableTextView
==========================
An expandable TextView for Android applications (4.0+).

[ ![Download](https://api.bintray.com/packages/blogcat/maven/android-expandabletextview/images/download.svg) ](https://bintray.com/blogcat/maven/android-expandabletextview/_latestVersion)

Demo
----
This repository also contains a demo project.

![Demo](https://raw.githubusercontent.com/Blogcat/Android-ExpandableTextView/release/1.0.0/demo.gif)

Add dependency
--------------
This library is not yet released in Maven Central, but instead you can use [Bintray](https://www.bintray.com).

```groovy
repositories {
maven {
url "https://dl.bintray.com/blogcat/maven"
}
}
```

library dependency

```groovy
dependencies {
compile ('at.blogc:expandabletextview:1.0.0@aar')
}
```

Usage
-----
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.

```xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<at.blogc.android.views.ExpandableTextView
android:id="@+id/expandableTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lorem_ipsum"
android:maxLines="5"
android:ellipsize="end"
app:animation_duration="1000"/>

<!-- Optional parameter animation_duration: sets the duration of the expand animation -->

<Button
android:id="@+id/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/expand"/>

</LinearLayout>
```

In your Activity or Fragment:

```java
final ExpandableTextView expandableTextView = (ExpandableTextView) this.findViewById(R.id.expandableTextView);
final Button buttonToggle = (Button) this.findViewById(R.id.button_toggle);

// set animation duration via code, but preferable in your layout files by using the animation_duration attribute
expandableTextView.setAnimationDuration(1000L);

// toggle the ExpandableTextView
buttonToggle.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(final View v)
{
expandableTextView.toggle();
buttonToggle.setText(expandableTextView.isExpanded() ? R.string.collapse : R.string.expand);
}
});

// but, you can also do the checks yourself
buttonToggle.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(final View v)
{
if (expandableTextView.isExpanded())
{
expandableTextView.collapse();
buttonToggle.setText(R.string.expand);
}
else
{
expandableTextView.expand();
buttonToggle.setText(R.string.collapse);
}
}
});

// listen for expand / collapse events
expandableTextView.setOnExpandListener(new ExpandableTextView.OnExpandListener()
{
@Override
public void onExpand(final ExpandableTextView view)
{
Log.d(TAG, "ExpandableTextView expanded");
}

@Override
public void onCollapse(final ExpandableTextView view)
{
Log.d(TAG, "ExpandableTextView collapsed");
}
});
```

Roadmap
=======

* take into account TextView padding and margin
* optional fading edge at the bottom of the TextView
* support for Interpolators
* update demo project with more examples

License
=======

Copyright 2016 Cliff Ophalvens (Blogc.at)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
108 changes: 0 additions & 108 deletions app/app.iml

This file was deleted.

5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':expandabletextview')


testCompile 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package blogc.at.android.views;
package at.blogc.android.views;

import android.app.Application;
import android.test.ApplicationTestCase;
Expand Down
18 changes: 16 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="blogc.at.android.views"
<!-- Copyright (C) 2016 Cliff Ophalvens (Blogc.at)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest package="at.blogc.android.views"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
Expand All @@ -8,7 +22,7 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="blogc.at.android.activities.MainActivity">
<activity android:name="at.blogc.android.activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand Down
Loading

0 comments on commit 320d85a

Please sign in to comment.