Как использовать NestedScrollView и BottomSheetBehavior вместе в CollapsingToolbarLayout? - PullRequest
0 голосов
/ 28 декабря 2018

Есть два фрагмента (дети) во фрагменте (мать).Материнский фрагмент имеет CollapsingToolbarLayout и имеет дочерние фрагменты со структурой вкладки под ним.

<!-- Mother Fragment -->
<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.honbabin.app.contents.store.MotherFragment">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/layoutMotherAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:elevation="0dp">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/layoutMotherCollapsingToolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:contentScrim="@color/white"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:toolbarId="@+id/toolbarMother">

            <!-- Code -->

          </android.support.design.widget.CollapsingToolbarLayout>

      </android.support.design.widget.AppBarLayout>

          <LinearLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              app:layout_behavior="@string/appbar_scrolling_view_behavior"
              tools:context="com.honbabin.app.contents.store.MotherFragment"
              tools:showIn="@layout/fragment_store_detail">

              <View
                  android:layout_width="match_parent"
                  android:layout_height="1px"
                  android:layout_below="@+id/layoutMotherActions"
                  android:background="@color/grey_200" />

              <android.support.design.widget.TabLayout
                  android:id="@+id/tabMotherInfo"
                  android:layout_width="match_parent"
                  android:layout_height="@dimen/dp_48"
                  android:background="@color/white"
                  android:textSize="@dimen/dp_15"
                  app:tabIndicatorColor="@color/transparent"
                  app:tabSelectedTextColor="@color/red_a200"
                  app:tabTextColor="@color/grey_300" />

              <View
                  android:layout_width="match_parent"
                  android:layout_height="1px"
                  android:background="@color/grey_200" />

              <com.honbabin.base.widget.NonSwipeableViewPager
                  android:id="@+id/pagerMotherInfo"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent" />

          </LinearLayout>
      </android.support.design.widget.CoordinatorLayout>

Дочерний фрагмент использует NestedScrollView.Его внутренний список (RecyclerView и т. Д.) Необходимо прокручивать с помощью CollapsingToolbarLayout.

<!-- Child Fragment -->
<android.support.v4.widget.NestedScrollView
    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.support.design.widget.CoordinatorLayout
        android:id="@+id/layoutChild"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:descendantFocusability="blocksDescendants">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/listChild"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/layoutChildCommentDivider"
                android:nestedScrollingEnabled="true" />
            <!-- Code -->

        </RelativeLayout>

        <!-- Code -->

        <LinearLayout
            android:id="@+id/layoutChildBottomSheet"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_bottom_sheet_menu"
            android:elevation="@dimen/dp_16"
            android:orientation="vertical"
            app:behavior_hideable="true"
            app:layout_behavior="@string/bottom_sheet_behavior">

            <!-- Code -->

            <TextView
                android:id="@+id/textChildBottomCancel"
                android:layout_width="match_parent"
                android:layout_height="@dimen/dp_56"
                android:background="@drawable/btn_rect_white"
                android:drawableStart="@drawable/ic_talk_more_cancel"
                android:drawablePadding="@dimen/dp_15"
                android:fontFamily="@font/font_notosans_light"
                android:gravity="center_vertical"
                android:paddingStart="@dimen/dp_17"
                android:text="@string/cancel"
                android:textColor="@color/grey_400"
                android:textSize="@dimen/dp_16" />

        </LinearLayout>

    </android.support.design.widget.CoordinatorLayout>

</android.support.v4.widget.NestedScrollView>

Я хотел бы, чтобы при выборе элемента Item RecyclerView появлялось BottomSheet .Теперь, когда я использую BottomSheetBehavior, BottomSheet появляется в нижней части списка RecyclerView.BottomSheet отображается внизу списка повторного просмотра, а не внизу экрана.

Как использовать BottomSheet (с CoordinatorLayout) с помощью NestedScrollView?

...