Comments (13)
I forgot to mention one thing, I am using your library with this https://github.com/cymcsg/UltimateRecyclerView could that be any reason for a clash? Do let me know thanks
from expandabletextview.
I may have figured out whats causing this, unlike the ListView where the getView will be called every time and you are the one whose deciding if the view should be recycled or not, thats not the case with a recyclerview, the onCreateViewHolder and onBindViewHolder are called initially when no recycled views are available but later the only method that gets triggered is the onBindViewHolder, does this have something to do with the SparseBooleanArray because I am binding it inside the onBindViewHolder, so the thing is, items that are towards the end of the list or the ones that are being created from recyled views expand and collapse correctly but not the ones at the beginning, take a look at this screenshot, the one at the start incurs both the onCreateViewHolder and the onBindViewHolder whereas the one at the bottom is simply recycled directly with the onBindViewHolder
from expandabletextview.
Thanks for the info. I will take a look this weekend and get back to you.
from expandabletextview.
I met a problem when I set ExpandableTextView's orientation horizontal:
<com.netease.cartoonreader.view.ExpandableTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:expandableTextView="http://schemas.android.com/apk/res-auto"
android:id="@+id/expand_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
expandableTextView:animAlphaStart="1"
expandableTextView:animDuration="200"
expandableTextView:maxCollapsedLines="4">
<TextView
android:id="@id/expandable_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageButton
android:id="@id/expand_collapse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent" />
</com.netease.cartoonreader.view.ExpandableTextView>
In a item of RecyclerView, when the state of ExpandableTextView is expandle, and scroll the RecyclerView to make this item rebind(onBindViewHolder again), click the ExpandableTextView will make the text invisible.
The problem is solved by setting TextView's layout_width "wrap_content". But I don't know why.
from expandabletextview.
I had similar issue with ExpandableTextview
in AOSP which this library is based on.
I solved it by simply using the plain old TextView
and keeping expanded status my self. Whenever the onBindViewHolder
is called, check the expanded status, and then setMaxLines
to Integer.MAX_VALUE
when it should be expanded or max lines you want when it should be collapsed. You may also opt-in for animation by calling notifyItemChanged(int position)
.
Hope this is helpful. 😺
Ref #18
from expandabletextview.
is the issue fixed which was mentioned by slidenerd....?
from expandabletextview.
#44 This thread has the proper solution to this issue
from expandabletextview.
Encountered the same problem, how to solve?
from expandabletextview.
@wmq389122157 @mohanraj546 @slidenerd @aaronhe42 If the content of the TextView is long enough, you can set mAnimationDuration = 0, setDuration (mAnimationDuration), and cancel the animation
from expandabletextview.
@Mixiaomi Thank you very much. The problem is settled. Thanks again!
from expandabletextview.
@Mixiaomi Thank you. It Worked.
from expandabletextview.
Hi, I am also facing an issue. While using the ExpandableTextView inside RecyclerView, whenever I am trying to collapse the TextView it becomes invisible.
from expandabletextview.
i solve this problem. when this view detach from window , animion might not finish。you can use ValueAnimator。here is the code:
`@Override
public void onClick(View view) {
if (mStateTv.getVisibility() != View.VISIBLE) {
return;
}
mCollapsed = !mCollapsed;
mStateTv.setText(mCollapsed ? mExpandString : mCollapsedString);
// mStateTv.setCompoundDrawablesWithIntrinsicBounds(mCollapsed ? mExpandDrawable : mCollapseDrawable, null, null, null);
if (mCollapsedStatus != null) {
mCollapsedStatus.put(mPosition, mCollapsed);
}
// mark that the animation is in progress
mAnimating = true;
//Animation animation;
if (mCollapsed) {
finalHeight = mCollapsedHeight;
} else {
finalHeight = getHeight() +
mTextHeightWithMaxLines - mTv.getHeight();
}
animateExpandView(this, getHeight(), finalHeight);
}
private void animateExpandView(View mTargetView, int mStartHeight, int mEndHeight) {
mAnimating = true;
ValueAnimator animator = ValueAnimator.ofInt(mStartHeight, mEndHeight);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(mAnimationDuration);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final int newHeight = (int) animation.getAnimatedValue();
mTv.setMaxHeight(newHeight - mMarginBetweenTxtAndBottom);
mTargetView.getLayoutParams().height = newHeight;
mTargetView.requestLayout();
}
});
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
Utils.Log.e("Expand animator onAnimationEnd");
clearAnimation();
// clear the animation flag
mAnimating = false;
Utils.Log.e("Expand onAnimationEnd");
// notify the listener
if (mListener != null) {
mListener.onExpandStateChanged(mTv, !mCollapsed);
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
animator.start();
}
`
from expandabletextview.
Related Issues (20)
- TextView 内容足够长,超出一屏, mCollapsedHeight计算的有问题 HOT 7
- 和recyclerview配合一起使用的时候下拉刷新
- mCollapsedHeight always 0 , when click to close the ExpandView
- i set spannablestring in the text,it works error in recycleview when i collapse the it HOT 2
- shit
- How to hide the image button and create custom button? HOT 1
- Write the widget in xml ,but show nothing in screen.Anything wrong? HOT 5
- 内容显示不全
- In the recyclerview, the expansion does not display the entire content correctly. HOT 4
- Can not works with androidx in android 3.3 version and gradle version 3.3.0
- AndroidX
- There is no support for collapsing an already expanded textview. HOT 1
- I cannot add three dots while ExpandableTextView is Collapsed
- Not Compatible with AndroidX (Empty screen) HOT 1
- MaxLines on expanded TextView?
- How to set custom expand/collapse ImageButtons src? HOT 1
- Duplicate Issue Created by Mistake | GitHub Bug -.- | IGNORE
- Duplicate Issue Created by Mistake | GitHub Bug -.- | IGNORE
- Solution for "Text is not completely shown in Expanded State (Height Calculation Issue)" HOT 2
- Support for Android X
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expandabletextview.