{"id":326472,"date":"2021-07-15T09:00:21","date_gmt":"2021-07-15T09:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=326472"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=326472","title":{"rendered":"BottomSheetDialogFragment \u0441 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 sticky button"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u043e\u0447\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0430\u043d\u0434\u0440\u043e\u0439\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 BottomSheetBehavior, \u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0440\u0435\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c BottomSheet, \u0430 \u0435\u0449\u0451 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u043b\u0438\u0431\u043e \u043f\u0440\u0438\u0433\u0432\u043e\u0437\u0434\u0438\u0442\u044c  \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u0438.<br \/>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0435\u0451 \u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0433\u0438\u0444\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/485\/cb9\/4c4\/485cb94c412ed20e0cd95133b4c39e88.gif\" width=\"432\" height=\"768\"><figcaption><\/figcaption><\/figure>\n<h2>\u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c:<\/h2>\n<ul>\n<li>\n<p>\u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e<\/p>\n<\/li>\n<li>\n<p>Kotlin<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 BottomSheetDialogFragment \u0438 BottomSheetBehavior<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435  LayoutParams<\/p>\n<\/li>\n<li>\n<p>ViewBinding(\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 findViewById)<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u0430\u043f<\/h2>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043c\u0435\u043d\u0443 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0432 BottomSheetDialogFragment, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0432 \u044d\u0442\u043e fading \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u043c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 drawable \u0444\u0430\u0439\u043b \u043f\u043e\u0434 \u0438\u043c\u0435\u043d\u0435\u043c <em>bottom_sheet_background.xml<\/em>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0438\u0448\u0435\u043c background \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0432 \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430 \u0438 \u0437\u0430\u043a\u0440\u0443\u0433\u043b\u0451\u043d\u043d\u044b\u0435 \u0443\u0433\u043b\u044b<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;shape xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"&gt;     &lt;corners         android:bottomLeftRadius=\"0dp\"         android:bottomRightRadius=\"0dp\"         android:topLeftRadius=\"10dp\"         android:topRightRadius=\"10dp\" \/&gt;     &lt;padding         android:bottom=\"0dip\"         android:left=\"0dip\"         android:right=\"0dip\"         android:top=\"0dip\" \/&gt;     &lt;solid android:color=\"#ffffff\" \/&gt; &lt;\/shape&gt;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0438\u0448\u0435\u043c \u0441\u0442\u0438\u043b\u044c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 <em>styles.xml<\/em> \u0432 \u043f\u0430\u043f\u043a\u0435 values<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; &lt;resources&gt;      &lt;style name=\"AppBottomSheetDialogTheme\"         parent=\"Theme.Design.Light.BottomSheetDialog\"&gt;         &lt;item name=\"bottomSheetStyle\"&gt;@style\/AppModalStyle&lt;\/item&gt;     &lt;\/style&gt;      &lt;style name=\"AppModalStyle\"         parent=\"Widget.Design.BottomSheet.Modal\"&gt;         &lt;item name=\"android:background\"&gt;@drawable\/bottom_sheet_background&lt;\/item&gt;     &lt;\/style&gt;  &lt;\/resources&gt;<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <em>bottom_sheet_layout.xml<\/em> \u0441 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u043e\u0439 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0432 xml \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>bottom_sheet_layout.xml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; &lt;androidx.constraintlayout.widget.ConstraintLayout 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=\"match_parent\"&gt;      &lt;!-- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c layout \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f     \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u0435\u0439\u0441\u0435 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 TextView \u0441 compound drawable, \u043d\u043e \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e LinearLayout \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438--&gt;     &lt;LinearLayout         android:id=\"@+id\/layout_top\"         android:layout_width=\"match_parent\"         android:layout_height=\"100dp\"         android:orientation=\"horizontal\"         app:layout_constraintStart_toStartOf=\"parent\"         app:layout_constraintTop_toTopOf=\"parent\"&gt;          &lt;ImageView             android:id=\"@+id\/simple_image\"             android:layout_width=\"48dp\"             android:layout_height=\"match_parent\"             android:importantForAccessibility=\"no\"             app:srcCompat=\"@drawable\/ic_launcher_foreground\"             app:tint=\"#32CD32\" \/&gt;          &lt;TextView             android:id=\"@+id\/simple_text\"             android:layout_width=\"match_parent\"             android:layout_height=\"48dp\"             android:layout_gravity=\"center\"             android:gravity=\"center\"             android:text=\"Text and image in linear layout\"             android:textSize=\"20sp\" \/&gt;      &lt;\/LinearLayout&gt;      &lt;!-- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c layout \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u0434\u043b\u044f collapsed \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 --&gt;     &lt;LinearLayout         android:id=\"@+id\/layout_collapsed\"         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:orientation=\"vertical\"         app:layout_constraintStart_toStartOf=\"parent\"         app:layout_constraintTop_toBottomOf=\"@id\/layout_top\"&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"30dp\"             android:gravity=\"center\"             android:textStyle=\"italic\"             android:text=\"Text about something\"             android:textSize=\"24sp\" \/&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"100dp\"             android:gravity=\"center\"             android:text=\"Some element, for example RecyclerView\"             android:textSize=\"32sp\" \/&gt;      &lt;\/LinearLayout&gt;      &lt;!-- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c layout \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430     \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 invisible \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 layout_top \u043a\u0430\u043a \u0438 layout_collapsed--&gt;     &lt;LinearLayout         android:id=\"@+id\/layout_expanded\"         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:orientation=\"vertical\"         android:visibility=\"invisible\"         app:layout_constraintStart_toStartOf=\"parent\"         app:layout_constraintTop_toBottomOf=\"@id\/layout_top\"&gt;          &lt;LinearLayout             android:layout_width=\"match_parent\"             android:layout_height=\"72dp\"             android:orientation=\"vertical\"&gt;              &lt;TextView                 android:layout_width=\"match_parent\"                 android:layout_height=\"24dp\"                 android:gravity=\"center\"                 android:text=\"First Line\"                 android:textSize=\"20sp\" \/&gt;              &lt;TextView                 android:layout_width=\"match_parent\"                 android:layout_height=\"24dp\"                 android:gravity=\"center\"                 android:text=\"Second Line\"                 android:textSize=\"20sp\" \/&gt;              &lt;TextView                 android:layout_width=\"match_parent\"                 android:layout_height=\"24dp\"                 android:gravity=\"center\"                 android:text=\"Third Line\"                 android:textSize=\"20sp\" \/&gt;          &lt;\/LinearLayout&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"30dp\"             android:layout_marginTop=\"16dp\"             android:gravity=\"center\"             android:text=\"Text about something\"             android:textSize=\"24sp\" \/&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"180dp\"             android:gravity=\"center\"             android:text=\"Some bigger element, for example bigger RecyclerView\"             android:textSize=\"36sp\" \/&gt;      &lt;\/LinearLayout&gt;  &lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt;<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0412 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043e\u0434\u043d\u0443 ViewGroup, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u0442\u0435\u0439\u0442\u0430\u0445 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f, \u0438 \u0434\u0432\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 ViewGroup \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 collapsed \u0438 expanded.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u043d\u0438\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0447\u0435\u0437\u0430\u0442\u044c \u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 BottomFragment, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432 \u0435\u0433\u043e \u043e\u0442 BottomSheetDialogFragment<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 BottomFragment<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">private const val COLLAPSED_HEIGHT = 228  class BottomFragment : BottomSheetDialogFragment() {      \/\/ \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c findViewById     lateinit var binding: BottomSheetLayoutBinding      \/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0435\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0441 \u0437\u0430\u043a\u0440\u0443\u0433\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0443\u0433\u043b\u0430\u043c\u0438     override fun getTheme() = R.style.AppBottomSheetDialogTheme      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {         binding = BottomSheetLayoutBinding.bind(inflater.inflate(R.layout.bottom_sheet_layout, container))         return binding.root     }      \/\/ \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0416\u0426, \u0438 \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0434\u0430\u0447\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e     \/\/ \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0435 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0416\u0426, \u0430 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 onCreateDialog()     override fun onStart() {         super.onStart()          \/\/ \u041f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c         val density = requireContext().resources.displayMetrics.density          dialog?.let {             \/\/ \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u0430\u043c bottomSheet \u0438 \u0434\u043e\u0441\u0442\u0430\u0451\u043c \u0438\u0437 \u043d\u0435\u0433\u043e Behaviour             val bottomSheet = it.findViewById&lt;View&gt;(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout             val behavior = BottomSheetBehavior.from(bottomSheet)              \/\/ \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u044b\u0441\u043e\u0442\u0443 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f collapsed \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 collapsed             behavior.peekHeight = (COLLAPSED_HEIGHT * density).toInt()             behavior.state = BottomSheetBehavior.STATE_COLLAPSED              behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {                  override fun onStateChanged(bottomSheet: View, newState: Int) {                     \/\/ \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043b\u0431\u0435\u043a\u0443                 }                  override fun onSlide(bottomSheet: View, slideOffset: Float) {                     with(binding) {                         \/\/ \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0444\u0444\u0441\u0435\u0442, \u0442\u043a \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043d\u0430\u0441 \u0443\u0441\u0442\u0440\u043e\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 - \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430                         if (slideOffset &gt; 0) {                             \/\/ \u0414\u0435\u043b\u0430\u0435\u043c \"\u0441\u0432\u0451\u0440\u043d\u0443\u0442\u044b\u0439\" layout \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c                             layoutCollapsed.alpha = 1 - 2 * slideOffset                             \/\/ \u0418 \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u0435\u043b\u0430\u0435\u043c \"\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 layout\" \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c                             layoutExpanded.alpha = slideOffset * slideOffset                              \/\/ \u041a\u043e\u0433\u0434\u0430 \u043e\u0444\u0444\u0441\u0435\u0442 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443, \u043c\u044b \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c collapsed layout \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0438\u0434\u0438\u043c\u044b\u043c expanded                             if (slideOffset &gt; 0.5) {                                 layoutCollapsed.visibility = View.GONE                                 layoutExpanded.visibility = View.VISIBLE                             }                              \/\/ \u0415\u0441\u043b\u0438 \u0436\u0435 \u043e\u0444\u0444\u0441\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b, \u0430 expanded layout \u0432\u0441\u0451 \u0435\u0449\u0451 \u0432\u0438\u0434\u0435\u043d, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c collapsed                             if (slideOffset &lt; 0.5 &amp;&amp; binding.layoutExpanded.visibility == View.VISIBLE) {                                 layoutCollapsed.visibility = View.VISIBLE                                 layoutExpanded.visibility = View.INVISIBLE                             }                         }                     }                 }             })         }     } }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b<\/p>\n<ul>\n<li>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c BottomSheetBehavior, \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u043c\u0443 peekHeight  \u0438 \u0432\u0435\u0448\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 onSlide() \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0444\u0444\u0441\u0435\u0442\u0430 \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0438\u0445 \u0434\u0432\u0443\u0445 layout \u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u0435\u043d\u044f\u0435\u043c \u0438\u0445 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 0.5 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0438 \u0442\u043e\u0433\u0434\u0430 \u0438\u0441\u0447\u0435\u0437\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u043f\u043e\u0437\u0436\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u0437\u043e\u0432\u0435\u043c \u043d\u0430\u0448 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442. \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0438 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0438, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 onCreate() \u0432 MainActivity<\/p>\n<pre><code class=\"kotlin\">class MainActivity : AppCompatActivity() {          override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)          BottomFragment().show(supportFragmentManager, \"tag\")     } }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442. \u041c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/54f\/f6c\/64d\/54ff6c64d4682bb27b0f13b74725e118.gif\" width=\"432\" height=\"768\"><figcaption><\/figcaption><\/figure>\n<h2>\u0412\u0442\u043e\u0440\u043e\u0439 \u044d\u0442\u0430\u043f<\/h2>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c sticky \u043a\u043d\u043e\u043f\u043a\u0443 \u0432\u043d\u0438\u0437\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c view \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u044d\u043a\u0440\u0430\u043d\u0443.<\/p>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c layout \u0444\u0430\u0439\u043b <em>button.xml<\/em> \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 <\/p>\n<pre><code class=\"xml\">&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"     android:layout_width=\"match_parent\"     android:layout_height=\"match_parent\"     android:background=\"#ffffff\"&gt;      &lt;Button         android:id=\"@+id\/button_a\"         android:layout_width=\"match_parent\"         android:layout_height=\"60dp\"         android:layout_marginStart=\"8dp\"         android:layout_marginEnd=\"8dp\"         android:backgroundTint=\"#32CD32\"         android:text=\"Sticky Button\" \/&gt;  &lt;\/LinearLayout&gt;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0443, \u0432\u0441\u0442\u0430\u0432\u0438\u0432 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 <em>behavior.state <\/em>\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u043b\u0431\u0435\u043a\u0430 behavior.addBottomSheetCallback<\/p>\n<pre><code class=\"kotlin\">\/\/ \u0414\u043e\u0441\u0442\u0430\u0451\u043c \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0435 \u043b\u044d\u0439\u0430\u0443\u0442\u044b             val coordinator = (it as BottomSheetDialog).findViewById&lt;CoordinatorLayout&gt;(com.google.android.material.R.id.coordinator)             val containerLayout = it.findViewById&lt;FrameLayout&gt;(com.google.android.material.R.id.container)              \/\/ \u041d\u0430\u0434\u0443\u0432\u0430\u0435\u043c \u043d\u0430\u0448 \u043b\u044d\u0439\u0430\u0443\u0442 \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439             val buttons = it.layoutInflater.inflate(R.layout.button, null)              \/\/ \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0438             buttons.layoutParams = FrameLayout.LayoutParams(                 FrameLayout.LayoutParams.MATCH_PARENT,                 FrameLayout.LayoutParams.WRAP_CONTENT             ).apply {                 height = (60 * density).toInt()                 gravity = Gravity.BOTTOM             }             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440             containerLayout?.addView(buttons)              \/\/ \u041f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043b\u044d\u0439\u0430\u0443\u0442             buttons.post {                 (coordinator?.layoutParams as ViewGroup.MarginLayoutParams).apply {                     buttons.measure(                         View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),                         View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)                     )                     \/\/ \u0423\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0430\u0437\u0440\u044b\u0432 \u043c\u0435\u0436\u0434\u0443 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u0438 \u0441\u043a\u0440\u043e\u043b\u044f\u0449\u0435\u0439\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e                     this.bottomMargin = (buttons.measuredHeight - 8 * density).toInt()                     containerLayout?.requestLayout()                 }             }<\/code><\/pre>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b:<\/p>\n<ul>\n<li>\n<p>\u041c\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u043d\u0430\u0434\u0443\u0432\u0430\u0435\u043c \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448 layout \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c\u0443 layout<\/p>\n<\/li>\n<li>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043a\u043d\u043e\u043f\u043a\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0438\u043d\u0438\u0442\u044c \u043d\u0430\u0448 layout \u043b\u044e\u0431\u044b\u043c\u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 view<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/712\/1d3\/0ef\/7121d30efc76437b298abeeaa0050e83.gif\" width=\"432\" height=\"768\"><figcaption><\/figcaption><\/figure>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 <\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">private const val COLLAPSED_HEIGHT = 228  class BottomFragment : BottomSheetDialogFragment() {      \/\/ \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c findViewById     lateinit var binding: BottomSheetLayoutBinding      \/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0435\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0441 \u0437\u0430\u043a\u0440\u0443\u0433\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0443\u0433\u043b\u0430\u043c\u0438     override fun getTheme() = R.style.AppBottomSheetDialogTheme      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {         binding = BottomSheetLayoutBinding.bind(inflater.inflate(R.layout.bottom_sheet_layout, container))         return binding.root     }      \/\/ \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0416\u0426, \u0438 \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0434\u0430\u0447\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e     \/\/ \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0435 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0416\u0426, \u0430 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 onCreateDialog()     override fun onStart() {         super.onStart()          \/\/ \u041f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c         val density = requireContext().resources.displayMetrics.density          dialog?.let {             \/\/ \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u0430\u043c bottomSheet \u0438 \u0434\u043e\u0441\u0442\u0430\u0451\u043c \u0438\u0437 \u043d\u0435\u0433\u043e Behaviour             val bottomSheet = it.findViewById&lt;View&gt;(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout             val behavior = BottomSheetBehavior.from(bottomSheet)              \/\/ \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u044b\u0441\u043e\u0442\u0443 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f collapsed \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 collapsed             behavior.peekHeight = (COLLAPSED_HEIGHT * density).toInt()             behavior.state = BottomSheetBehavior.STATE_COLLAPSED              \/\/ \u0414\u043e\u0441\u0442\u0430\u0451\u043c \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0435 \u043b\u044d\u0439\u0430\u0443\u0442\u044b             val coordinator = (it as BottomSheetDialog).findViewById&lt;CoordinatorLayout&gt;(com.google.android.material.R.id.coordinator)             val containerLayout = it.findViewById&lt;FrameLayout&gt;(com.google.android.material.R.id.container)              \/\/ \u041d\u0430\u0434\u0443\u0432\u0430\u0435\u043c \u043d\u0430\u0448 \u043b\u044d\u0439\u0430\u0443\u0442 \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439             val buttons = it.layoutInflater.inflate(R.layout.button, null)              \/\/ \u0412\u044b\u0441\u0442\u0430\u0432\u043e\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0438             buttons.layoutParams = FrameLayout.LayoutParams(                 FrameLayout.LayoutParams.MATCH_PARENT,                 FrameLayout.LayoutParams.WRAP_CONTENT             ).apply {                 height = (60 * density).toInt()                 gravity = Gravity.BOTTOM             }             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440             containerLayout?.addView(buttons)              \/\/ \u041f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043b\u044d\u0439\u0430\u0443\u0442             buttons.post {                 (coordinator?.layoutParams as ViewGroup.MarginLayoutParams).apply {                     buttons.measure(                         View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),                         View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)                     )                     \/\/ \u0423\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0430\u0437\u0440\u044b\u0432 \u043c\u0435\u0436\u0434\u0443 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u0438 \u0441\u043a\u0440\u043e\u043b\u044f\u0449\u0435\u0439\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e                     this.bottomMargin = (buttons.measuredHeight - 8 * density).toInt()                     containerLayout?.requestLayout()                 }             }              behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {                  override fun onStateChanged(bottomSheet: View, newState: Int) {                     \/\/ \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043b\u0431\u0435\u043a\u0443                 }                  override fun onSlide(bottomSheet: View, slideOffset: Float) {                     with(binding) {                         \/\/ \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0444\u0444\u0441\u0435\u0442, \u0442\u043a \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043d\u0430\u0441 \u0443\u0441\u0442\u0440\u043e\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 - \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430                         if (slideOffset &gt; 0) {                             \/\/ \u0414\u0435\u043b\u0430\u0435\u043c \"\u0441\u0432\u0451\u0440\u043d\u0443\u0442\u044b\u0439\" layout \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c                             layoutCollapsed.alpha = 1 - 2 * slideOffset                             \/\/ \u0418 \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u0435\u043b\u0430\u0435\u043c \"\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 layout\" \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c                             layoutExpanded.alpha = slideOffset * slideOffset                              \/\/ \u041a\u043e\u0433\u0434\u0430 \u043e\u0444\u0444\u0441\u0435\u0442 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443, \u043c\u044b \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c collapsed layout \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0438\u0434\u0438\u043c\u044b\u043c expanded                             if (slideOffset &gt; 0.5) {                                 layoutCollapsed.visibility = View.GONE                                 layoutExpanded.visibility = View.VISIBLE                             }                              \/\/ \u0415\u0441\u043b\u0438 \u0436\u0435 \u043e\u0444\u0444\u0441\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b, \u0430 expanded layout \u0432\u0441\u0451 \u0435\u0449\u0451 \u0432\u0438\u0434\u0435\u043d, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c collapsed                             if (slideOffset &lt; 0.5 &amp;&amp; binding.layoutExpanded.visibility == View.VISIBLE) {                                 layoutCollapsed.visibility = View.VISIBLE                                 layoutExpanded.visibility = View.INVISIBLE                             }                         }                     }                 }             })         }     } }<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p><a href=\"https:\/\/github.com\/goldenluk\/AnimatedBottomSheet\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u043e\u0442 \u0437\u0434\u0435\u0441<\/a>\u044c <\/p>\n<p>\u0414\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u0442 \u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e \u0432\u0435\u0440\u043d\u043e\u0435. <\/p>\n<p>\u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u0442\u0430\u043a\u0438\u0445!<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c\u0438, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438 \u0438 \u0442\u0434, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0433\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0434 \u0432\u0430\u0448\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435! \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f\u043c \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/567828\/\"> https:\/\/habr.com\/ru\/post\/567828\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u043e\u0447\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0430\u043d\u0434\u0440\u043e\u0439\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 BottomSheetBehavior, \u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0440\u0435\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c BottomSheet, \u0430 \u0435\u0449\u0451 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u043b\u0438\u0431\u043e \u043f\u0440\u0438\u0433\u0432\u043e\u0437\u0434\u0438\u0442\u044c  \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u0438.<br \/>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0435\u0451 \u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0433\u0438\u0444\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<h2>\u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c:<\/h2>\n<ul>\n<li>\n<p>\u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e<\/p>\n<\/li>\n<li>\n<p>Kotlin<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 BottomSheetDialogFragment \u0438 BottomSheetBehavior<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435  LayoutParams<\/p>\n<\/li>\n<li>\n<p>ViewBinding(\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 findViewById)<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u0430\u043f<\/h2>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043c\u0435\u043d\u0443 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0432 BottomSheetDialogFragment, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0432 \u044d\u0442\u043e fading \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u043c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 drawable \u0444\u0430\u0439\u043b \u043f\u043e\u0434 \u0438\u043c\u0435\u043d\u0435\u043c <em>bottom_sheet_background.xml<\/em>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0438\u0448\u0435\u043c background \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0432 \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430 \u0438 \u0437\u0430\u043a\u0440\u0443\u0433\u043b\u0451\u043d\u043d\u044b\u0435 \u0443\u0433\u043b\u044b<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;shape xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"&gt;     &lt;corners         android:bottomLeftRadius=\"0dp\"         android:bottomRightRadius=\"0dp\"         android:topLeftRadius=\"10dp\"         android:topRightRadius=\"10dp\" \/&gt;     &lt;padding         android:bottom=\"0dip\"         android:left=\"0dip\"         android:right=\"0dip\"         android:top=\"0dip\" \/&gt;     &lt;solid android:color=\"#ffffff\" \/&gt; &lt;\/shape&gt;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0438\u0448\u0435\u043c \u0441\u0442\u0438\u043b\u044c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 <em>styles.xml<\/em> \u0432 \u043f\u0430\u043f\u043a\u0435 values<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; &lt;resources&gt;      &lt;style name=\"AppBottomSheetDialogTheme\"         parent=\"Theme.Design.Light.BottomSheetDialog\"&gt;         &lt;item name=\"bottomSheetStyle\"&gt;@style\/AppModalStyle&lt;\/item&gt;     &lt;\/style&gt;      &lt;style name=\"AppModalStyle\"         parent=\"Widget.Design.BottomSheet.Modal\"&gt;         &lt;item name=\"android:background\"&gt;@drawable\/bottom_sheet_background&lt;\/item&gt;     &lt;\/style&gt;  &lt;\/resources&gt;<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <em>bottom_sheet_layout.xml<\/em> \u0441 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u043e\u0439 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0432 xml \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>bottom_sheet_layout.xml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; &lt;androidx.constraintlayout.widget.ConstraintLayout 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=\"match_parent\"&gt;      &lt;!-- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c layout \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f     \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u0435\u0439\u0441\u0435 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 TextView \u0441 compound drawable, \u043d\u043e \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e LinearLayout \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438--&gt;     &lt;LinearLayout         android:id=\"@+id\/layout_top\"         android:layout_width=\"match_parent\"         android:layout_height=\"100dp\"         android:orientation=\"horizontal\"         app:layout_constraintStart_toStartOf=\"parent\"         app:layout_constraintTop_toTopOf=\"parent\"&gt;          &lt;ImageView             android:id=\"@+id\/simple_image\"             android:layout_width=\"48dp\"             android:layout_height=\"match_parent\"             android:importantForAccessibility=\"no\"             app:srcCompat=\"@drawable\/ic_launcher_foreground\"             app:tint=\"#32CD32\" \/&gt;          &lt;TextView             android:id=\"@+id\/simple_text\"             android:layout_width=\"match_parent\"             android:layout_height=\"48dp\"             android:layout_gravity=\"center\"             android:gravity=\"center\"             android:text=\"Text and image in linear layout\"             android:textSize=\"20sp\" \/&gt;      &lt;\/LinearLayout&gt;      &lt;!-- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c layout \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u0434\u043b\u044f collapsed \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 --&gt;     &lt;LinearLayout         android:id=\"@+id\/layout_collapsed\"         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:orientation=\"vertical\"         app:layout_constraintStart_toStartOf=\"parent\"         app:layout_constraintTop_toBottomOf=\"@id\/layout_top\"&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"30dp\"             android:gravity=\"center\"             android:textStyle=\"italic\"             android:text=\"Text about something\"             android:textSize=\"24sp\" \/&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"100dp\"             android:gravity=\"center\"             android:text=\"Some element, for example RecyclerView\"             android:textSize=\"32sp\" \/&gt;      &lt;\/LinearLayout&gt;      &lt;!-- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c layout \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430     \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 invisible \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 layout_top \u043a\u0430\u043a \u0438 layout_collapsed--&gt;     &lt;LinearLayout         android:id=\"@+id\/layout_expanded\"         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:orientation=\"vertical\"         android:visibility=\"invisible\"         app:layout_constraintStart_toStartOf=\"parent\"         app:layout_constraintTop_toBottomOf=\"@id\/layout_top\"&gt;          &lt;LinearLayout             android:layout_width=\"match_parent\"             android:layout_height=\"72dp\"             android:orientation=\"vertical\"&gt;              &lt;TextView                 android:layout_width=\"match_parent\"                 android:layout_height=\"24dp\"                 android:gravity=\"center\"                 android:text=\"First Line\"                 android:textSize=\"20sp\" \/&gt;              &lt;TextView                 android:layout_width=\"match_parent\"                 android:layout_height=\"24dp\"                 android:gravity=\"center\"                 android:text=\"Second Line\"                 android:textSize=\"20sp\" \/&gt;              &lt;TextView                 android:layout_width=\"match_parent\"                 android:layout_height=\"24dp\"                 android:gravity=\"center\"                 android:text=\"Third Line\"                 android:textSize=\"20sp\" \/&gt;          &lt;\/LinearLayout&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"30dp\"             android:layout_marginTop=\"16dp\"             android:gravity=\"center\"             android:text=\"Text about something\"             android:textSize=\"24sp\" \/&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"180dp\"             android:gravity=\"center\"             android:text=\"Some bigger element, for example bigger RecyclerView\"             android:textSize=\"36sp\" \/&gt;      &lt;\/LinearLayout&gt;  &lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt;<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0412 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043e\u0434\u043d\u0443 ViewGroup, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u0442\u0435\u0439\u0442\u0430\u0445 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f, \u0438 \u0434\u0432\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 ViewGroup \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 collapsed \u0438 expanded.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u043d\u0438\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0447\u0435\u0437\u0430\u0442\u044c \u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 BottomFragment, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432 \u0435\u0433\u043e \u043e\u0442 BottomSheetDialogFragment<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 BottomFragment<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">private const val COLLAPSED_HEIGHT = 228  class BottomFragment : BottomSheetDialogFragment() {      \/\/ \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c findViewById     lateinit var binding: BottomSheetLayoutBinding      \/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0435\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0441 \u0437\u0430\u043a\u0440\u0443\u0433\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0443\u0433\u043b\u0430\u043c\u0438     override fun getTheme() = R.style.AppBottomSheetDialogTheme      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {         binding = BottomSheetLayoutBinding.bind(inflater.inflate(R.layout.bottom_sheet_layout, container))         return binding.root     }      \/\/ \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0416\u0426, \u0438 \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0434\u0430\u0447\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e     \/\/ \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0435 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0416\u0426, \u0430 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 onCreateDialog()     override fun onStart() {         super.onStart()          \/\/ \u041f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c         val density = requireContext().resources.displayMetrics.density          dialog?.let {             \/\/ \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u0430\u043c bottomSheet \u0438 \u0434\u043e\u0441\u0442\u0430\u0451\u043c \u0438\u0437 \u043d\u0435\u0433\u043e Behaviour             val bottomSheet = it.findViewById&lt;View&gt;(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout             val behavior = BottomSheetBehavior.from(bottomSheet)              \/\/ \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u044b\u0441\u043e\u0442\u0443 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f collapsed \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 collapsed             behavior.peekHeight = (COLLAPSED_HEIGHT * density).toInt()             behavior.state = BottomSheetBehavior.STATE_COLLAPSED              behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {                  override fun onStateChanged(bottomSheet: View, newState: Int) {                     \/\/ \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043b\u0431\u0435\u043a\u0443                 }                  override fun onSlide(bottomSheet: View, slideOffset: Float) {                     with(binding) {                         \/\/ \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0444\u0444\u0441\u0435\u0442, \u0442\u043a \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043d\u0430\u0441 \u0443\u0441\u0442\u0440\u043e\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 - \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430                         if (slideOffset &gt; 0) {                             \/\/ \u0414\u0435\u043b\u0430\u0435\u043c \"\u0441\u0432\u0451\u0440\u043d\u0443\u0442\u044b\u0439\" layout \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c                             layoutCollapsed.alpha = 1 - 2 * slideOffset                             \/\/ \u0418 \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u0435\u043b\u0430\u0435\u043c \"\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 layout\" \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c                             layoutExpanded.alpha = slideOffset * slideOffset                              \/\/ \u041a\u043e\u0433\u0434\u0430 \u043e\u0444\u0444\u0441\u0435\u0442 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443, \u043c\u044b \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c collapsed layout \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0438\u0434\u0438\u043c\u044b\u043c expanded                             if (slideOffset &gt; 0.5) {                                 layoutCollapsed.visibility = View.GONE                                 layoutExpanded.visibility = View.VISIBLE                             }                              \/\/ \u0415\u0441\u043b\u0438 \u0436\u0435 \u043e\u0444\u0444\u0441\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b, \u0430 expanded layout \u0432\u0441\u0451 \u0435\u0449\u0451 \u0432\u0438\u0434\u0435\u043d, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c collapsed                             if (slideOffset &lt; 0.5 &amp;&amp; binding.layoutExpanded.visibility == View.VISIBLE) {                                 layoutCollapsed.visibility = View.VISIBLE                                 layoutExpanded.visibility = View.INVISIBLE                             }                         }     <\/code><\/pre>\n<\/div>\n<\/details>\n<p><\/br><\/br><\/p>\n<p><\/br><\/p>\n<\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-326472","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326472"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326472\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}