android - 在android中滚动底部工作表的问题
问题描述
我在 Android 中的底部工作表的问题是,当我向上滚动工作表时,它会填满整个活动。我需要我的底片在某个高度停下来。
下面是我的代码:
activity_main.xml:-
<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"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click here"
tools:layout_editor_absoluteX="161dp"
tools:layout_editor_absoluteY="272dp"
tools:ignore="MissingConstraints" />
<include
layout="@layout/bottom_sheet"
android:layout_height="79dp" />
</android.support.design.widget.CoordinatorLayout>
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
linearLayout = (LinearLayout)findViewById(R.id.linearlayour);
bottomSheetBehavior = BottomSheetBehavior.from(linearLayout);
bottomSheetBehavior.setPeekHeight(200);
}
下面是我的 bottom_sheet.xml 文件:-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:id="@+id/linearlayour"
app:behavior_peekHeight="100dp">
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_weight="1"
android:text="Inside bottom" />
我需要我的底部床单停在某个高度。我无法让它像那样工作。请帮忙。提前致谢
解决方案
使用 bottomsheet 的 peekHeight 属性设置它可以滚动的最大高度 max
<FrameLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:fitsSystemWindows="true"
app:behavior_hideable="false"
app:behavior_peekHeight="200dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<include layout="@layout/bottom_sheet_content_view" />
</FrameLayout>
推荐阅读
- python - 根据可变时间条件将行拆分为多行
- curl - Libcurl 不会在 cookie.txt 中正确写入 cookie
- windows - 从 Windows 远程备份树莓派 sd 卡
- php - Drupal删除/删除内容中包含特定单词的所有页面
- python-3.x - 如何检查一组元组中的一个元组切片是否在另一组元组中?
- python - Python 如何在另一个类方法中使用一个类
- python - TypeError:常量属性不能有 WRITE 方法或 NOTIFY 信号
- r - R web在多个页面上抓取图表
- mysql - 合并对mysql中重复行的引用
- google-rich-snippets - 谷歌 sRich 片段。从 https://schema.org 重定向到 http://schema.org