Weird Animation Comes For RecyclerView Last Item

2019-07-04 12:18发布

I have two views in my RecyclerView single item , two RelativeLayouts, at some point I am flipping both RelativeLayouts, I am rotating the LayoutA from 0 to 180 degree, and the same time I does rotating the LayoutB from -180 to 0, so will get a flipping feel. It works perfect, but when there is no space in screen (ex: for the last item of RecyclerView) then I am getting the weird effect, before starting this flip Animation LayoutB(which is hidden initially) expands and hides then animation starts

Flip out

   <set xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Rotate. -->
    <objectAnimator
            android:valueFrom="0"
            android:valueTo="180"
            android:propertyName="rotationY"
            android:interpolator="@android:interpolator/accelerate_decelerate"
            android:duration="1000" />

    <objectAnimator
            android:valueFrom="1.0"
            android:valueTo="0.0"
            android:propertyName="alpha"
            android:startOffset="0"
            android:duration="1000" />

</set>

Flip in

 <set xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Rotate. -->
    <objectAnimator
            android:valueFrom="180"
            android:valueTo="0"
            android:propertyName="rotationY"
            android:interpolator="@android:interpolator/accelerate_decelerate"
            android:duration="1000" />

    <objectAnimator
            android:valueFrom="0.0"
            android:valueTo="1.0"
            android:propertyName="alpha"
            android:duration="1000"
            android:startOffset="0"/>
</set>

Adapter Code

    AnimatorSet setRightOut = (AnimatorSet) AnimatorInflater.loadAnimator
            (mContext, R.animator.flip_right_out);
    AnimatorSet setLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(mContext,
            R.animator.flip_left_in);

    setRightOut.setTarget(holder.layoutA);
    setRightOut.setDuration(1500);
    setLeftIn.setTarget(holder.layoutB);
    setLeftIn.setDuration(1500);
    setLeftIn.start();
    setRightOut.start();

logcat prints this repeatedly though I am not making any calls to scrollToPosition method

Logcat

  W/RecyclerView: RecyclerView does not support scrolling to an absolute position. Use scrollToPosition instead

Is there any fix for this ?

0条回答
登录 后发表回答