2016-09-17 113 views

回答

0

是的,你可以實現這一目標。只需將RelativeLayout作爲父級佈局,然後添加包括您的視圖/佈局,並分配屬性alignParentBottom = 「true」。然後包括你的RecyclerView並添加layout_above =「included_layout_id」

0

我都包裹着我的內容視圖中的另一個視圖(rootContent)內只爲範圍,以獲得高度,但你可以得到它以更好的方式。然後在底部表格回調

mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); 

    mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { 
     @Override 
     public void onStateChanged(@NonNull View bottomSheet, int newState) { 
      if(newState == BottomSheetBehavior.STATE_COLLAPSED){ 
       content.getLayoutParams().height = rootContent.getHeight(); 
      }else { 
       content.getLayoutParams().height = rootContent.getHeight() - bottomSheet.getHeight(); 
      } 
      content.requestLayout(); 
     } 

     @Override 
     public void onSlide(@NonNull View bottomSheet, float slideOffset) { 

     } 
    }); 
1

是的,你可以這樣做。你只需要使用BottomSheetCallback您BottomSheetBehavior,像這樣:

bottomSheetBehavior = BottomSheetBehavior.from(yourLayoutWithBottomSheetBehavior); 
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { 

    @Override 
    public void onStateChanged(@NonNull View bottomSheet, int newState) { 

    } 

    @Override 
    public void onSlide(@NonNull View bottomSheet, float slideOffset) { 

     CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) yourRecyclerView.getLayoutParams();   
     layoutParams.height = bottomSheet.getTop(); 
     yourRecyclerView.setLayoutParams(layoutParams);   
     yourRecyclerView.requestLayout(); 
}); 

在onSlide方法,你總能得到底片目前上方,如果你改變狀態或將其拖拽。

相關問題