2017-08-29 152 views
0

我尝试将视图添加到RecyclerView时,点击ButtonViewHolder中。将视图添加到RecyclerView

enter image description here

当点击ButtonViewHolder3,一个视图(视图中添加更多)将增加并且出现上述情况类似的图像。

ViewAddMore将固定在那里,RecyclerView可以正常滚动。

我试过但没有找到任何解决方案,我的问题; 对我的问题有任何建议吗?

+0

那么,你想在哪里看到ViewAddMore? – Raghavendra

+0

@Raghavendra:它是动态的。当用户点击按钮时,ViewAddMore将出现在ViewHolder1和ViewHolder2上方。 –

+0

我建议你不要这样做。它真的很糟糕的设计,通过一个弹出框来阻止您的recyclerViews视图。 –

回答

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; 
     } 
    }); 
  1. https://developer.android.com/reference/android/widget/PopupWindow.html

  2. How to make a simple android popup window?

希望这会帮助你。