0

I tried to add view into RecyclerView when click to Button in a ViewHolder.

enter image description here

When click to Button in ViewHolder3, a View (view add more) will add and appear like image above.

ViewAddMore will pin there and RecyclerView can scroll normal.

I tried but don't found any solution for my issue; Have any suggest for my issue?

Community
  • 1
  • 1
Sinh Phan
  • 1,180
  • 3
  • 16
  • 36

1 Answers1

0

Please use PopupWindow to show this View.

// get a reference to the already created main layout
    LinearLayout mainLayout = (LinearLayout) findViewById(R.id.activity_main_layout);

    // inflate the layout of the popup window
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View popupView = inflater.inflate(R.layout.popup_window, null);

    // create the popup window
    int width = LinearLayout.LayoutParams.WRAP_CONTENT;
    int height = LinearLayout.LayoutParams.WRAP_CONTENT;
    boolean focusable = true; // lets taps outside the popup also dismiss it
    final PopupWindow popupWindow = new PopupWindow(popupView, width, height, focusable);

    // show the popup window
    popupWindow.showAtLocation(mainLayout, Gravity.CENTER, 0, 0);

    // dismiss the popup window when touched
    popupView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            popupWindow.dismiss();
            return true;
        }
    });
  1. https://developer.android.com/reference/android/widget/PopupWindow.html

  2. How to make a simple android popup window?

Hope this will help you.

Yogendra
  • 4,817
  • 1
  • 28
  • 21