我想創建一個使用recyclerView這樣example臥式使用動畫RecyclerView
我能夠創建RecyclerView選擇器,使之貼緊使用SnapHelper但無法建立動畫我一個選擇器。 任何人都可以告訴我如何創建基於recyclerView中物品位置的動畫嗎?
我想創建一個使用recyclerView這樣example臥式使用動畫RecyclerView
我能夠創建RecyclerView選擇器,使之貼緊使用SnapHelper但無法建立動畫我一個選擇器。 任何人都可以告訴我如何創建基於recyclerView中物品位置的動畫嗎?
要爲在回收站視圖中單擊的項目設置動畫,您需要將動畫應用到回收站視圖列表項目的視圖。
這可以通過
定義View.OnClickListener或View.OnTouchListener在recyclerview適配器的 Viewholder來完成。
最後,將必要的動畫應用到 聽衆的視圖中。
上回收視圖
@Override
public void onBindViewHolder(ViewHolder holder, int position)
{
holder.text.setText(items.get(position));
// Here you apply the animation when the view is bound
setAnimation(holder.itemView, position);
}
嘗試此動畫和動畫的方法會像
private void setAnimation(View viewToAnimate, int position)
{
// If the bound view wasn't previously displayed on screen, it's animated
if (position > lastPosition)
{
Animation animation = AnimationUtils.loadAnimation(context, android.R.anim.slide_in_left);
viewToAnimate.startAnimation(animation);
lastPosition = position;
}
}
希望這有助於
謝謝,但我已經嘗試過這一點,它不工作,因爲我想,但它的其他動畫好。我想我的動畫響應拖動不僅項目更改 –
您是否嘗試過使用'ItemTouchHelper'? –
不,但我一定會研究它 –
謝謝你,我會試試看 –
請讓我知道它是否有效。 –