show or hide part of text only in a TextView
Only 70 addtional methods added using this library.
dependencies {
compile 'com.timqi.collapsibletextview:library:1.1.2'
}
You can download the demo apk directly or compile manually using:
./gradlew assembleDebug
To set the full text of CollapsibleTextView
CollapsibleTextView mCollapsibleTextView = (CollapsibleTextView) findViewById(R.id.normal);
mCollapsibleTextView.setFullString(mLongText);
Set status expanded or collapsed
mCollapsibleTextView.setExpanded(true);
//mCollapsibleTextView.setExpanded(false);
<com.timqi.collapsibletextview.CollapsibleTextView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
app:collapsedLines="2"
app:collapsedText=" Show All"
app:expandedText=" Hide"
app:suffixColor="#0000ff"
app:suffixTrigger="true" // whether it is triggered by suffix only
/>
// value is a proper value
mCollapsibleTextView.setCollapsedLines(1);
mCollapsibleTextView.setCollapsedText(" Show Text");
mCollapsibleTextView.setExpandedText(" Hide Text");
mCollapsibleTextView.setSuffixColor(0xff0000ff);
mCollapsibleTextView.setSuffixTrigger(true);
Join and pull request for whatever you want.
Copyright 2017 Tim Qi
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.