vip*_*per 6 android android-layout material-design android-coordinatorlayout bottom-sheet
我正在尝试使用BottomSheetBehavior类似于Google地图所提供的布局。我成功使用BottomSheetBehavior并创建了向上滑动的布局。我现在遇到的问题是CordinatorLayout即使我的布局崩溃了也要占用额外的空间。下面是我的布局的屏幕截图。
我的主布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content">
<include layout="@layout/sample_coordinator" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
具有BottomSheetBehavior的CordinatorLayout
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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="wrap_content"
android:background="@color/common_google_signin_btn_text_light_disabled">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:behavior_hideable="false"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<TextView
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@color/colorPrimary" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
小智 8
您必须在活动布局中使用CoordinatorLayout。然后在底部工作表布局中插入以下行:
app:behavior_hideable="true"
app:behavior_peekHeight="Xdp"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
202 次 |
| 最近记录: |