2017-08-29 141 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?

希望這會幫助你。