blogcat / android-expandabletextview Goto Github PK
View Code? Open in Web Editor NEWAn expandable TextView for Android applications
Home Page: http://www.blogc.at
License: Apache License 2.0
An expandable TextView for Android applications
Home Page: http://www.blogc.at
License: Apache License 2.0
i don't want to play animation. how to remove that?
Assume we have a textview with variable text inside. The text can change from 3 lines or up to 20 lines.
If we set the duration as let's say 300ms, the 3 line scenario will be too slow and 20 lines maybe too fast.
Is there a way to have a method to set duration according to how many lines are in the TV?
setDurationPerLine(int)
Step 1. Expand/Collapse works well for the 1st time when RecyclerView is rendered on UI.
Step 2. Now scroll the RecyclerView (so that ExpandableTextView loses focus), and go back to ExpandableTextView.
Step 3. Now try to Expand/Collapse it. Doesn't work. :(
Am not able to set the custom font to ExpandableTextView in XML it shows the font I selected but while running the app it uses the default font. Any Suggestion?
If we have different categories of ExpandablePlaceHolders and we often switch between them to load different data, caching the data for each placeholder is more efficient and quicker than removing all views, and repopulating the placeholders. What is the best way to do this here? The placeHolder.getAdapter().notifyDataSetChanged();
does not seem to work.
When using the ExpandableTextView with the attributes gravity="center" to center the text in combination with ellipsize="end", the collapsed layout of the last line is a bit off.
Collapsed state:
Expanded state:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<at.blogc.android.views.ExpandableTextView
android:id="@+id/textViewDescription"
style="@style/BodyNormal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:ellipsize="end"
android:lineSpacingExtra="2sp"
android:maxLines="3"
android:textColor="@color/blackAlpha87"
app:animation_duration="500"
tools:text="A look at the life of the astronaut, Neil Armstrong, and the legendary space mission that led him to become the first man to ..."/>
<Button
android:id="@+id/buttonViewMore"
style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/view_more"
android:textAppearance="@style/Button"
android:textColor="?android:attr/colorPrimary"/>
</LinearLayout>
Any idea when version 1.1.0 will be released? Or is the library dying off?
Currently, if we toggle while the view is animating, nothing will happen.
In other words, the action is not cancelable until full expand/retract.
Can the toggle method support toggling while animation is in progress?
I am using down arrow and up arrow for collapse and expand. Expanding text works in sync with down arrow as this arrow is statically defined in layout file. I am facing problem while collapsing. I am using below code to change the image icon
` mExpandableTextView.setOnExpandListener(new ExpandableTextView.OnExpandListener() {
@OverRide
public void onExpand(ExpandableTextView view) {
mImageView.setImageResource(R.drawable.up_arrow);
}
@Override
public void onCollapse(ExpandableTextView view) {
mImageView.setImageResource(R.drawable.down_arrow);
}
});`
but it seems drawable is updated immediately but Textview takes a time to collapse. Can you please help me on this?
I have a problem with the OvershootInterpolator, the issue says:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void at.blogc.android.views.ExpandableTextView.setInterpolator(android.animation.TimeInterpolator)' on a null object reference
at com.company.jobs.jobsproject.MainActivity.onCreate(MainActivity.java:51)
And that line is this:
ETW_Perfil_Empresa.setInterpolator(new OvershootInterpolator());
In expandablelistview i already done expand/collapse action.But ,For this view i want to parse data from JSON to display parent and child data.
Normal State:
Nulla malesuada urna et bibendum imperdiet.
Expand State:
Nulla malesuada urna et bibendum imperdiet.\n\n
https://www.dropbox.com/s/95pic2wumblc38n/device-2016-11-01-161547.mp4?dl=0
see the screen record example
I can't build this project
I cannot be able to see the ellipsize with the ExpandableTextView while parsing the Text to HTML with the Spannable String
After expanding / collapsing the ExpandableTextview and rotating the device, it sometimes happens that the calculated height of the TextView isn't correct anymore.
The solution would be that ExpandableTextview sets the height back to WRAP_CONTENT after expanding or collapsing.
I am happy to work with this library. For now, I want to add justify alignment on the text. The text justified property will need to be kept for both status Expanded and Collapsed. how can I do it?
ExnpandableTextView
doesn't maintain expanded state changes between orientation/config changes.
How to reproduce:
android:configChanges
from manifest of current Demo.ExpandableTextView
.ExpandableTextView loses its expanded state.
If you change the landscape orientation does not appear ellipsis end (...)
How determine if need expand the text?
Hello ,
I wanna set up maxLine with code.
I tried to set maxLines in your code, but it does not work.
Tks.
It doesn't work anymore on Android 8 (Oreo). TextView is auto expanded and it's not possible to collapse it. Tested on Nexus 6P device.
Hello,
My issue is that the button to expand the text only works on the first try. When I load the screen, I can expand the text correctly. However, when I try to collapse it, it looks like it's collapsing but then it expands again and then the button does not collapse or expand anything anymore. Running debug I can see that it is running collapse() method... It just is not correctly collapsing.
Hi,
Thanks for creating this ExpandableTextView, it is exactly what I am looking to do, however, I'm not sure what I am missing because the textview is not expanding or collapsing for me.
I have the following ExpandableTextView in my layout:
<at.blogc.android.views.ExpandableTextView
android:id="@+id/tv_JobDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="@color/laborswipe_darkgray"
android:text="aasdf
a
a
a
a
"
android:maxLines="5"
android:ellipsize="end"
android:background="@color/white"/>
I am trying to expand the ExpandableTextView in my adapter class like this:
public class JobAdapter extends ArrayAdapter<Job> {
private final Context context;
private final ArrayList<Job> jobs;
private final int layoutResourceId;
private ExpandableTextView desc = null;
private Button expand = null;
private boolean isExpanded = false;
public JobAdapter(Context context, int layoutResourceId, ArrayList<Job> jobs) {
super(context, layoutResourceId, jobs);
this.context = context;
this.jobs = jobs;
this.layoutResourceId = layoutResourceId;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
ViewHolder holder = null;
LayoutInflater inflater = (LayoutInflater) context.getSystemService((Activity.LAYOUT_INFLATER_SERVICE));
if (view == null) {
view = inflater.inflate(layoutResourceId, parent, false);
holder = new ViewHolder();
holder.title = (TextView)view.findViewById(R.id.tv_jobTitle);
//holder.description = (ExpandableTextView)view.findViewById(R.id.tv_JobDesc);
desc = (ExpandableTextView)view.findViewById(R.id.tv_JobDesc);
//holder.expand = (Button) view.findViewById(R.id.btn_descExpand);
expand = (Button) view.findViewById(R.id.btn_descExpand);
view.setTag(holder);
} else {
holder = (ViewHolder)view.getTag();
}
Job j = jobs.get(position);
holder.title.setText(j.getJobTitle());
//holder.description.setText(j.getDescription());
desc.setText(j.getDescription());
// set animation duration via code, but preferable in your layout files by using the animation_duration attribute
desc.setAnimationDuration(1000L);
// set interpolators for both expanding and collapsing animations
desc.setInterpolator(new OvershootInterpolator());
// or set them separately
desc.setExpandInterpolator(new OvershootInterpolator());
desc.setCollapseInterpolator(new OvershootInterpolator());
//when user clicks the expand/collapse button, expand or collapse the description field
holder.expand.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
System.out.println("Expanding Button Clicked!");
desc.toggle();
expand.setText(desc.isExpanded() ? "Collapse" : "Expand");
}
});
// listen for expand / collapse events
desc.setOnExpandListener(new ExpandableTextView.OnExpandListener() {
@Override
public void onExpand(final ExpandableTextView view) {
Log.d("TextView", "ExpandableTextView expanded");
}
@Override
public void onCollapse(final ExpandableTextView view) {
Log.d("TextView", "ExpandableTextView collapsed");
}
});
return view;
}
static class ViewHolder
{
TextView title;
ExpandableTextView description;
Button expand;
}
}
I'm not sure what I am missing, am I not able to use the ExpandableTextView in a custom adapter?
Thanks for the help!
Expanded View is so much gap after pagination.
Getting multiple edittext fields dynamically from JSON response.To save edittext data need to get id of edittext.How to get ids for edittext in android
It is possible in the future that can withstand minimal version of the api 15?
.setInterpolator()
Add custom interpolator for animation collapse and expand, usage with EasingInterpolator
Error:Execution failed for task ':app:processProductionMinSdk21DebugManifest'.
Manifest merger failed : Attribute application@supportsRtl value=(false) from AndroidManifest.xml:16:9-36
is also present at [at.blogc:expandabletextview:1.0.2] AndroidManifest.xml:29:9-35 value=(true).
Suggestion: add 'tools:replace="android:supportsRtl"' to element at AndroidManifest.xml:10:5-172:19 to override.
How can you get if you need to expand the text? ie when the text takes up very little , so as not to show the expand button .
In addition to onExpand/onCollapse events that fire when expand/collapse animation starts, it would be great to get onExpandFinished/onCollapseFinished events that fire when the corresponding animation finishes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.