Giter Club home page Giter Club logo

Comments (13)

slidenerd avatar slidenerd commented on June 15, 2024

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.

slidenerd avatar slidenerd commented on June 15, 2024

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
testgif

from expandabletextview.

Manabu-GT avatar Manabu-GT commented on June 15, 2024

Thanks for the info. I will take a look this weekend and get back to you.

from expandabletextview.

fengshenzhu avatar fengshenzhu commented on June 15, 2024

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.

aaronweihe avatar aaronweihe commented on June 15, 2024

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.

mohanraj546 avatar mohanraj546 commented on June 15, 2024

is the issue fixed which was mentioned by slidenerd....?

from expandabletextview.

nangsan avatar nangsan commented on June 15, 2024

#44 This thread has the proper solution to this issue

from expandabletextview.

CleverMod avatar CleverMod commented on June 15, 2024

Encountered the same problem, how to solve?

from expandabletextview.

Mixiaomi avatar Mixiaomi commented on June 15, 2024

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

CleverMod avatar CleverMod commented on June 15, 2024

@Mixiaomi Thank you very much. The problem is settled. Thanks again!

from expandabletextview.

monikagupta94 avatar monikagupta94 commented on June 15, 2024

@Mixiaomi Thank you. It Worked.

from expandabletextview.

pk4393 avatar pk4393 commented on June 15, 2024

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.

Greatkingcj avatar Greatkingcj commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.