Android CV系列 > 可拖拽布局 拉长 CoordinatorLayout +BottomSheetBehavior

1.

//noinspection GradleCompatible
implementation 'com.android.support:design:26.1.0'

2.MainAc

<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical"
    tools:context="com.as.app2.MainActivity">

    <TextView
        android:background="#f00"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <include layout="@layout/content"/>
</android.support.design.widget.CoordinatorLayout>

2.content

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="340dp"
    android:background="#ff0"
    android:orientation="vertical"
    app:behavior_hideable="false"
    android:layout_marginTop="10dp"
    app:behavior_peekHeight="80dp"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="bottom_sheet_content"
        android:textColor="@android:color/white" />

</LinearLayout>

猜你喜欢

转载自blog.csdn.net/FlyPig_Vip/article/details/81985485
今日推荐