RecyclerView条目item点击事件---放大

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();

            }
        });

猜你喜欢

转载自blog.csdn.net/WhuiQi/article/details/84205117