2017-12-11 12 views
0

활동을 처음로드 할 때 하단 시트를 숨기고 싶습니다.동작을 사용하여 하단 시트를 어떻게 숨길 수 있습니까?

버튼을 클릭하면 아래쪽 시트가 표시됩니다.

그래서,이 같은

<LinearLayout 
     android:id="@+id/main_linearlayout_BottomSheet" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     app:behavior_hideable="true" 
     app:behavior_peekHeight="200dp" 
     app:layout_behavior="@string/bottom_sheet_behavior" 
     android:background="@drawable/mappoint_edge" 
     > 

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     bottomSheet.setState(BottomSheetBehavior.STATE_HIDDEN); 

} 

때 버튼을 클릭,

private void setButton() { 

if (!state){ 
     bottomSheet.setState(BottomSheetBehavior.STATE_COLLAPSED); 
    }else{ 
     bottomSheet.setState(BottomSheetBehavior.STATE_HIDDEN); 
    } 


} 

을 설정하지만이 몇 가지 문제가 있습니다.

onCreatebottomSheet.setState(BottomSheetBehavior.STATE_HIDDEN)을 입력하면 bottomSheet가 클릭해도 표시되지 않지만 삭제할 때 bottomSheet가 숨기고 표시됩니다.

bottomSheet.setState(BottomSheetBehavior.STATE_HIDDEN)을 어디에 배치 할 때 맨 아래 시트를 숨기려면? sheet.show() : 당신이 그것에 대해 알고 있다면

, 버튼을 사용하여 onClick() 내부

bottomSheetBehavior.setPeekHeight(200); 
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); 

답변

0

onCreate에서

bottomSheetBehavior.setPeekHeight(0); 
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); 

+0

iaaue를 해결 한 경우 올바른 답으로 투표하거나, 문제가 계속되는 경우 알려주십시오. –

0

회신 그리고 나는 그것을 보여줄 때하시기 바랍니다.

그런 다음이를 닫으려면 sheet.dismiss();

private void setButton() { 
    if (!state){ 
     bottomSheet.show() 
    }else{ 
     bottomSheet.dismiss() 
    } 
}