我有RecyclerView
哪个项目包含ImageView1
,TextView1
,TextView2
,ImageView2
。我希望当应用程序运行时,textView2
无限制地有一个动画slideInLeft,对于recyclerView
的每个项目,当您向下滚动并返回到某个项目时,动画将重新开始。如何动画只有一个字段的回收站查看项目
我TextView
在XML中看起来是这样的:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:textColor="@color/slideingText"
android:textSize="18sp"
android:layout_weight="2"
android:layout_marginRight="3dp"
android:text="this is some other text if you need this to be done you have to do it yourself"
android:layout_gravity="center"
android:singleLine="true"
android:focusable="true"
android:textStyle="bold"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:gravity="center"
android:scrollHorizontally="true"
android:id="@+id/currentShowTitle"/>
在我RecyclerVew适配器我做了这样的事情:
setAnimation(holder.currentShowTitle,position);
其中
private void setAnimation(View viewToAnimate, int position)
{
if (position > lastPosition)
{
Animation animation = AnimationUtils.loadAnimation(context, android.R.anim.slide_in_left);
viewToAnimate.startAnimation(animation);
lastPosition = position;
}
}
我也用
@Override
public void onViewDetachedFromWindow(ChannelsViewHolder holder) {
super.onViewDetachedFromWindow(holder);
((ChannelsViewHolder)holder).clearAnimation();
}
问题是,当应用程序运行时,它动画,因为我只想要第一个项目,当我向下滚动并回来时,动画不会再次开始。 有谁知道如何做到这一点?