安卓BottomSheetBehavior设置状态和peek不能改变view的高度,view的高度一直保持为设置的height
我想实现高度地图首页底部弹窗的效果.这个窗口我用线性布局器作为coordinator的子view,页面效果没问题,然而不能通过behaviour的peek,setState等设置窗口的高度。API31
//behaviour设置
bottomSheetBehavior=BottomSheetBehavior.from(fragmentBinding.bom);
bottomSheetBehavior.setState(STATE_COLLAPSED);
bottomSheetBehavior.setPeekHeight(10); //10px,如果设置成功view应该很小
//底部窗口的XML
<LinearLayout
android:id="@+id/bom"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/dialog"
android:backgroundTint="#364362"
android:orientation="vertical"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
...
</LinearLayout>
依然是xml的height=100dp属性设置的高度,而不是peek设置的10px