点击RecyclerView
中的Button
时,我尝试将视图添加到ViewHolder
。
点击Button
中的ViewHolder3
时,视图(视图添加更多)将添加并显示为上图。
ViewAddMore
会固定在那里,RecyclerView
可以正常滚动。
我试过,但没有为我的问题找到任何解决方案; 对我的问题有任何建议吗?
答案 0 :(得分:0)
请使用PopupWindow显示此视图。
// 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;
}
});