Я хочу отобразить постоянную нижнюю таблицу, чтобы отобразить некоторые детали, у меня есть следующий код для реализации. но обратный вызов не получает триггер, когда я устанавливаю новое состояние.
LinearLayout bottomSheetLayout = findViewById(R.id.bottomSheetLayout);
BottomSheetBehavior sheetBehavior;
sheetBehavior = BottomSheetBehavior.from(bottomSheetLayout);
sheetBehavior.setHideable(true);
sheetBehavior.setPeekHeight(0);
sheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
wholeBottomLayout.setVisibility(View.GONE);
} else if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
wholeBottomLayout.setVisibility(View.GONE);
} else if (newState == BottomSheetBehavior.STATE_EXPANDED) {
wholeBottomLayout.setVisibility(View.VISIBLE);
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
sheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
под кодом XML
<android.support.design.widget.CoordinatorLayout
android:id="@+id/wholeBottomLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:layout_marginTop="56dp">
<LinearLayout
android:id="@+id/bottomSheetLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="@color/white"
android:orientation="vertical"
android:paddingBottom="@dimen/_8sdp"
android:visibility="visible"
app:behavior_hideable="true"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ivCloseBlockSlot"
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/_8sdp"
android:background="@color/colorPrimary"
android:padding="@dimen/_6sdp"
android:src="@drawable/multiply" />
<com.mansion.provider.Utilities.MyTextView
android:id="@+id/closeBlockedSlot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="@dimen/_5sdp"
android:text="@string/close_block_slot"
android:textAlignment="center"
android:textColor="@color/black" />
<com.mansion.provider.Utilities.MyTextView
android:id="@+id/todayDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="@dimen/_5sdp"
android:textAlignment="center"
android:textColor="@color/black"
tools:text="Wednesday 05, September" />
<LinearLayout
android:id="@+id/fromLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_8sdp">
<com.mansion.provider.Utilities.MyTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:padding="@dimen/_5sdp"
android:text="@string/from"
android:textColor="@color/black" />
<com.mansion.provider.Utilities.MyTextView
android:id="@+id/tvFromDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:gravity="end"
android:padding="@dimen/_5sdp"
android:text="@string/sample_time"
android:textColor="@color/black" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="@dimen/_8sdp"
android:background="@color/dark_gray" />
<LinearLayout
android:id="@+id/toLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_8sdp">
<com.mansion.provider.Utilities.MyTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:padding="@dimen/_8sdp"
android:text="@string/to"
android:textColor="@color/black" />
<com.mansion.provider.Utilities.MyTextView
android:id="@+id/tvToDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:gravity="end"
android:padding="@dimen/_8sdp"
android:text="@string/sample_time"
android:textColor="@color/black" />
</LinearLayout>
<com.mansion.provider.Utilities.MyButton
android:id="@+id/save_blocked_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_10sdp"
android:background="@color/red"
android:text="@string/save_blocked_slot"
android:textColor="@color/black" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Когда я устанавливаю новое состояние для sheetBehavior, обратный вызов не срабатывает. Есть ли ошибка в коде? Кто-нибудь сталкивался с этим ??