Weird Animation Comes For RecyclerView Last Item

孤人 提交于 2019-12-12 14:05:16

问题


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 ?

来源:https://stackoverflow.com/questions/36566602/weird-animation-comes-for-recyclerview-last-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!