Adapter–创建接口
//创建接口
public interface RecyInterface{
void vh(Viewholder viewholder);
}
//声明接口名
private RecyInterface mRecyInterface;
//暴露方法
public void setRecyInterface (RecyInterface recyInterface){
mRecyInterface=recyInterface;
}
在onBind里写
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mRecyInterface.vh(holder);
}
});
Activity—放大动画
适配器调用接口
myRecyAdapter.setRecyInterface(new MyRecyAdapter.RecyInterface() {
@Override
public void vh(MyRecyAdapter.Viewholder viewholder) {
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator scaleX = ObjectAnimator.ofFloat(viewholder.itemView, "scaleX", new float[]{1f, 1.2f, 1f});
ObjectAnimator scaleY = ObjectAnimator.ofFloat(viewholder.itemView, "scaleY", new float[]{1f, 1.2f, 1f});
scaleX.setDuration(500);
scaleY.setDuration(500);
animatorSet.playTogether(scaleX,scaleY);
animatorSet.start();
}
});