片段(母亲)中有两个片段(孩子)。母片段具有CollapsingToolbarLayout,子片段下方具有Tab结构。
<!-- 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>
子Fragment正在使用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>
当我单击RecyclerView的项目时,我想显示 BottomSheet 。现在,当我使用BottomSheetBehavior时,BottomSheet出现在RecyclerView列表的底部。 BottomSheet显示在recyclerview列表的底部,而不是屏幕的底部。
如何通过NestedScrollView使用BottomSheet(带有CoordinatorLayout)?