I have a bottom sheet with a NestedScrollView inside (see below). When I press on a FAB button, I want to make some parts in this NestedScrollView invisible. But when I change some linearlayouts visibilities to GONE, bottomsheet fly aways from the top.
My XML code:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/messageOptionBottomSheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/back_miscellaneous"
android:gravity="center"
android:orientation="vertical"
app:behavior_peekHeight="0dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<View
android:id="@+id/divider2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/textSecondary" />
<LinearLayout
android:id="@+id/layoutDeleteMessage"
android:layout_width="match_parent"
android:layout_height="@dimen/_35sdp"
android:layout_margin="@dimen/_10sdp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:animateLayoutChanges="true"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="@dimen/_22sdp"
android:layout_height="@dimen/_22sdp"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_remove" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_10sdp"
android:fontFamily="@font/ubuntu_medium"
android:includeFontPadding="false"
android:text="@string/delete_message"
android:textColor="@color/textSecondary"
android:textSize="@dimen/_12ssp" />
<TextView
android:id="@+id/textConfirmDelete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/_10sdp"
android:fontFamily="@font/ubuntu_medium"
android:gravity="end"
android:includeFontPadding="false"
android:text="@string/confirm"
android:textColor="@color/red"
android:textSize="@dimen/_12ssp"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>