gpt4 book ai didi

android - 使用 Animation 使 ItemDecoration 移动

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:05:12 24 4
gpt4 key购买 nike

我在我的 RecyclerView 中实现了 ItemDecoration 以及每当加载 RV 时播放的动画。但是,我注意到在动画完成之前装饰已经出现在边界处,我想让装饰与动画同时移动。我该怎么做?

到目前为止,我一直是这样进入动画的:

@Override
public void onBindViewHolder(final RecyclerVH recyclerVH, final int position) {
currentNote = data.get(position);
final String currentTitle = currentNote.getTitle();
final String currentContent = currentNote.getContent();
final int currentPosition = currentNote.getPosition();
String currentAlarmDate = currentNote.getAlarm();

Log.d("RecyclerView", "onBindVH called: " + currentTitle);
Log.d("RecyclerView", "Position at: " + currentPosition + " and Adapter Position at: " + recyclerVH.getAdapterPosition());

// final Info currentObject = data.get(position);
// Current Info object retrieved for current RecyclerView item - USED FOR DELETE
recyclerVH.listTitle.setText(currentTitle);
recyclerVH.listContent.setText(currentContent);
Log.d("RecyclerAdapter", "currentAlarmDate is: '" + currentAlarmDate + "'");
if (currentAlarmDate != null && !currentAlarmDate.equals(" ")) {
Log.d("RecyclerAdapter", "Current Alarm set for: " + currentAlarmDate);
recyclerVH.alarm.setText(currentAlarmDate);
} else
recyclerVH.alarm.setText(R.string.no_alarm);

/*recyclerVH.listTitle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Open new Activity containing note content
Toast.makeText(this, "Opening: " + currentObject.title, Toast.LENGTH_LONG).show();
}
});*/
runEnterAnimation(recyclerVH.itemView, position);
}


private void runEnterAnimation(View itemView, int position) {
// Starts Animation

Animation animation = AnimationUtils.loadAnimation(context,
position >= lastAnimatedPosition ? R.anim.up_from_bottom : R.anim.down_from_top);
// If true, up_from_button is loaded
itemView.startAnimation(animation);
lastAnimatedPosition = position;
Log.d("RecyclerAdapter", "lastAnimatedPosition is now: " + lastAnimatedPosition);
}

最佳答案

@Mimmo Grottoli 的回答似乎是最接近解决方案的。查看这篇文章:How to disable RecyclerView item decoration drawing for the duration of item animations

关于android - 使用 Animation 使 ItemDecoration 移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36843322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com