2017-10-18 1 views
1

私のアプリでは、ボトムシートと折りたたみ/展開させるボタンがあります。私はpeekHeightを設定しないとBottomSheetBehaviorはドラッグできません

peekHeightが設定されていないと、下のシートがドラッグできず、折りたたまれず、常に表示されます。ここで

はコードです:間違っている

 View bottomSheet = findViewById(R.id.bottom_sheet1); 
     mBottomSheetBehavior1 = BottomSheetBehavior.from(bottomSheet); 

     mBottomSheetBehavior1.setPeekHeight(0); //IF I OMIT THIS, IT DOES NOT WORK 

     mButton1 = (Button) findViewById(R.id.button_1); 
     mButton1.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       if(mBottomSheetBehavior1.getState() != BottomSheetBehavior.STATE_EXPANDED) { 
        mBottomSheetBehavior1.setState(BottomSheetBehavior.STATE_EXPANDED); 
        mButton1.setText("Collapse 1"); 
       } 
       else { 
        mBottomSheetBehavior1.setState(BottomSheetBehavior.STATE_COLLAPSED); 
        mButton1.setText("Expand 1"); 
       } 
      } 
     }); 

何?

答えて

1

デフォルトでは、BottomSheetBehaviorではなく、hideableです。

あなたはその行動がhideableになりたいことを、明示的に指示する必要があり

 

    bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); 
    bottomSheetBehavior.setHideable(true); 
 
関連する問題