Home:ALL Converter>How listen change height bottom sheet layout android

How listen change height bottom sheet layout android

Ask Time:2020-06-20T04:35:49         Author:Pavel Zlotarenchuk

Json Formatter

I have the following code

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".ui.main.MainActivity">

    <fragment
        android:id="@+id/navHostFragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:defaultNavHost="true"
        app:navGraph="@navigation/main_graph" />

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="8dp">

        <include layout="@layout/bottom_sheet" />
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

And

<?xml version="1.0" encoding="utf-8"?><!--suppress AndroidUnknownAttribute -->
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/bottomSheet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bottom_sheet_corners"
    android:clickable="true"
    android:focusable="true"
    app:behavior_hideable="false"
    app:behavior_peekHeight="0dp"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
    tools:ignore="ContentDescription">

    <com.mobilemedia.tanuki.ui.view.RoundedView
        android:id="@+id/bottomSheetContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:topLeftCornerRadius="16dp"
        app:topRightCornerRadius="16dp">

        <fragment
            android:id="@+id/bottomSheetNavHostFragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:defaultNavHost="true"
            app:navGraph="@navigation/bottom_sheet_graph" />
    </com.mobilemedia.tanuki.ui.view.RoundedView>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/collapsedView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <View
            android:layout_width="32dp"
            android:layout_height="4dp"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:background="@drawable/bottom_sheet_indicator"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

I need to listen to the change in height bottom sheet layout for change the position of elements relative to this height

enter image description here

The item must always be at a height from bottom sheet despite the fact that he is on another fragment in navHostFragment

How listen change height from bottom sheet?

Author:Pavel Zlotarenchuk,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/62478205/how-listen-change-height-bottom-sheet-layout-android
yy