如何解决如何使Android底表保持任何高度由用户停止拖动底表来定义?
默认情况下,它位于STATE_EXPANDED,STATE_COLLAPSED等,但是我希望用户将其拖动到某个高度并保持它的高度,但是底部工作表将转到预定义状态之一(STATE_EXPANDED,STATE_COLLAPSED)并更改其高度。这是我的底页:STATE_EXPANDED STATE_COLLAPSED
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable name="bottomSheetHeight" type="float" />
</data>
<LinearLayout
android:id="@+id/bottom_sheet"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bgc1"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
app:behavior_hideable="false"
app:behavior_peekHeight="30dp"
app:behavior_draggable="true"
tools:viewBindingIgnore="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="?attr/bgc2">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/history"
android:textColor="?attr/titleTextColorAttr"
android:background="@null"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/history_recycler_view"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_width="match_parent"
android:layout_height="@{bottomSheetHeight,default = @dimen/bottomSheetHeight}"
android:background="@null" />
</LinearLayout>
</layout>
我真的不明白如何使它保持任何高度,请帮忙!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。