android - BottomSheetBehavior 填充
问题描述
我有这种片段布局。
<android.support.design.widget.CoordinatorLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackgroundBlack">
<MyCustomView
android:id="@+id/vBottomSlider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior" />
</android.support.design.widget.CoordinatorLayout>
对于我vBottomSlider
,我创建了一个BottomSheetBehavior
实例:
val bh = BottomSheetBehavior.from(vBottomSlider)
bh.isHideable = false
bh.peekHeight = 50.dpToPx
bh.setBottomSheetCallback(mBottomCallback)
这就是片段内部的全部内容。
我的主要活动布局如下所示:
<android.support.constraint.ConstraintLayout
android:id="@+id/vMainConstraint"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/fContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.aurelhubert.ahbottomnavigation.AHBottomNavigation
android:id="@+id/vNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" />
</android.support.constraint.ConstraintLayout>
对于我,fContent
我将底部设置padding
为vNavigation
高度。当我向下滚动 my时,我通过更改它来vBottomSlider
隐藏,并为 my设置(通过从 获取事件)。vNavigation
translationY
padding
fContent
onSlide
BottomSheetBehavior.BottomSheetCallback
用手指完全滑动,效果很好。但是,当我或以编程方式为我的实例fling
设置EXPANDED
或状态时,它不会完全滚动。这里总是有一些空间(它似乎是我的高度)。COLLAPSED
BottomSheetBehavior
vNavigation
解决方案
我已经设法通过编辑BottomSheetBehavior
. 我的解决方案有点hacky。如果您需要编辑类,请发送电子邮件。
推荐阅读
- javascript - 如何使用纯 Javascript 函数呈现多个 HTML 部分
- css - 使用自定义 SVG React 覆盖 AgGrid 行复选框
- python - EOFError:解压非空文件时输入不足
- php - header('Content-Type: image/jpeg') 不适用于 Firefox
- php - 使用 ajax 和 jQuery 传递表单和文件数据的问题
- scala - Avro4s:匿名函数的参数类型必须是完全已知的。(SLS 8.5)
- joomla - FABRIK:如何隐藏元素使用下拉元素
- javascript - 为什么 array.prototype.slice() 在子类数组上这么慢?
- python - 我该如何解决,ValueError:一个系列的真值是模棱两可的。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()
- javascript - 如何将用户名从 React Native 应用程序发送到 Dialogflow 以供机器人在响应中使用