1

이미지로 레이아웃을 만들려면 어떻게해야합니까?android RecyclerView 및 nestedscrollview

enter image description here

나는 mainActivity이 시도 :

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/htab_maincontent" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/htab_appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fitsSystemWindows="true" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/htab_collapse_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="256dp" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <ImageView 
      android:id="@+id/htab_header" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@drawable/header" 
      android:fitsSystemWindows="true" 
      android:scaleType="centerCrop" 
      app:layout_collapseMode="parallax" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/htab_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:gravity="top" 
      android:minHeight="?attr/actionBarSize" 
      app:layout_collapseMode="parallax" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:titleMarginTop="13dp" /> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/htab_tabs" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:layout_marginTop="?attr/actionBarSize" 
      app:layout_collapseMode="pin" 
      android:theme="@style/MyCustomTabLayout" 
      app:tabIndicatorColor="@android:color/white" /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/main_title" 
      android:layout_gravity="bottom" 
      android:layout_marginBottom="10dp" 
      android:layout_marginStart="20dp" 
      android:gravity="start" 
      android:textStyle="bold" 
      android:textSize="20dp" 
      android:textColor="@color/colorAccent" 
      app:layout_collapseMode="parallax" 
      android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" 
      android:maxLines="1" 
      android:text="test articles" 
      android:layout_marginLeft="20dp" /> 
    </android.support.design.widget.CollapsingToolbarLayout> 

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

    <android.support.v4.view.ViewPager 
     android:id="@+id/htab_viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

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

과 조각이는 viewPager 자리 표시 자한다 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/dummyfrag_bg" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:background="@color/background_material_light" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/colorAccent"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/scrollableview" 
     android:layout_width="match_parent" 
     android:layout_height="110dp"/> 


</LinearLayout> 

<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/grid_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:numColumns="2" 
     android:columnWidth="90dp" 
     android:horizontalSpacing="10dp" 
     android:verticalSpacing="10dp" 
     android:gravity="center" 
     android:stretchMode="columnWidth" 
     android:nestedScrollingEnabled="false"/> 
</LinearLayout> 

문제는 다음과 같습니다 그리드 뷰 스크롤이 축소되지 않습니다 appbar. 격자보기가 스크롤 될 때 Appbar와 수평 RecyclerView를 축소하려고합니다.

답변

0

GridView에는 이미 스크롤 기능이 내장되어 있으므로 NestedScrollView과 충돌합니다. NestedScrollView 대신 RecyclerViewGridLayoutManagerappbar_scrolling_view_behavior 레이아웃 동작을 사용해야합니다.
이 대답은 here