RecyclerView Swipe with a view below it

前端 未结 6 1020
囚心锁ツ
囚心锁ツ 2020-12-07 11:24

I have been doing some research and I have yet to find an example or implementation that allows you to put a view (Example Image Below) underneath the RecyclerView when you

6条回答
  •  粉色の甜心
    2020-12-07 11:39

    I like the @erik approach but I would recommend to drawing what you want via passed Canvas to onChildDraw() function. e.g. item background or icon.

    @Override 
    public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
        final ColorDrawable background = new ColorDrawable(Color.RED);
        background.setBounds(0, itemView.getTop(),   itemView.getLeft() + dX, itemView.getBottom());
        background.draw(c);
    
        super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
    }
    

    In this approach, you will draw what needed on demand and no need to inflate unused views

提交回复
热议问题