当设计库更新到24.2.0时,BottomSheetBehavior不起作用 [英] BottomSheetBehavior is not work when design library update to 24.2.0
问题描述
BottomSheetBehavior在
BottomSheetBehavior work properly in
compile 'com.android.support:design:24.1.1'
但是当我将其更新到24.2.0时,它不起作用.这是一个错误吗? 这是我的代码:
but when I update it to 24.2.0,it is not work.Is that a bug? This is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
<LinearLayout
android:id="@+id/llScroll"
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="vertical"
android:background="@color/blue_1"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
推荐答案
STATE_COLLAPSED:隐藏底部工作表的一部分
STATE_HIDDEN:隐藏完整的底部工作表
在Support Library 24.2.0中,您必须设置窥视高度以指示折叠时希望底页显示多少像素.
In Support Library 24.2.0, you have to set the peek height to indicate how many pixels you want your bottom sheet to show when collapsed.
因此,如果您希望将其折叠并隐藏起来,则可以在初始化BottomSheetBehavior之后添加如下代码:
So if you want it to be collapsed and hid, you can add the code like this after you initialized your BottomSheetBehavior:
mBottomSheetBehavior.setPeekHeight(0);
这意味着当底部工作表折叠时,其高度将显示0像素.
that means when the bottom sheet collapsed, 0 pixel of its height will be shown.
或者您可以根据需要使其消失,请使用如下代码:
Or your can just make it disappear if you need, use the code like this:
mBottomSheetBehavior.setHideable(true);
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
这篇关于当设计库更新到24.2.0时,BottomSheetBehavior不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!