9

enter image description here Ich arbeite an einem Layout, so dass der ViewPager, der ein Fragment enthält, das Recycler View enthält, in einem Nester scrollView des Coordinator Layout platziert wird.Recycler Ansicht + View Pager + Verschachtelt ScrollView + CoordinatorLayout

Das Problem ist, wenn ich auf dem Recycler geklickt die verschachtelte Bildlaufansicht Ansicht funktioniert nicht ..

Gibt es eine Möglichkeit, ein Layout wie diese zu haben, die auch

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <LinearLayout 
      android:id="@+id/lin" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <ViewPager 
       android:id="@+id/view_pager" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 


     </LinearLayout> 


    <NestedScrollView> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

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

      <FrameLayout 
       android:layout_width="match_parent" 
       android:layout_height="190dp" 
       android:minHeight="190dp" 
       app:layout_collapseMode="parallax" > 

       <ViewFlipper 
        android:id="@+id/view_flipper" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"> 

        <!--<ImageView 
         android:id="@+id/backdrop" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:adjustViewBounds="true" 
         android:fitsSystemWindows="true" 
         android:scaleType="centerCrop"/>--> 

       </ViewFlipper> 

      </FrameLayout> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?actionBarSize" 
       app:layout_collapseMode="pin" /> 

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

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="?actionBarSize" 
      android:background="?attr/colorPrimary" /> 

    </android.support.design.widget.AppBarLayout> 
</android.support.design.widget.CoordinatorLayout> 
+0

Haben Sie es gelöst? –

Antwort

-3

Die ViewPager scrollt funktioniert nicht in einer NestedScrollView. Sie müssen es als Kind des CoordinatorLayout verwenden.

<android.support.design.widget.CoordinatorLayout 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"> 

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

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@android:color/transparent" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

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

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="190dp" 
      android:minHeight="190dp" 
      app:layout_collapseMode="parallax"> 

      <ViewFlipper 
       android:id="@+id/view_flipper" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <!--<ImageView 
        android:id="@+id/backdrop" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:adjustViewBounds="true" 
        android:fitsSystemWindows="true" 
        android:scaleType="centerCrop"/>--> 

      </ViewFlipper> 

     </FrameLayout> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?actionBarSize" 
      app:layout_collapseMode="pin" /> 

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

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="?actionBarSize" 
     android:background="?attr/colorPrimary" /> 

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

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

Verwenden Sie 「Recycler sehen + View Pager NestedScrollView + CoordinatorLayout」 nicht zur gleichen Zeit, entfernen Sie einfach die NestedScrollView es funktioniert gut ist.

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fitsSystemWindows="true" 
      app:expandedTitleTextAppearance="@android:color/transparent" 
      app:layout_collapseParallaxMultiplier="0.7" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      app:titleEnabled="false"> 

      <LinearLayout 
       android:id="@+id/header_view" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:animateLayoutChanges="true" 
       android:fitsSystemWindows="true" 
       android:orientation="vertical" 
       app:layout_collapseParallaxMultiplier="0.7"> 

       <..somethings..> 

      </LinearLayout> 

      <android.support.v7.widget.Toolbar 
       android:layout_width="match_parent" 
       android:layout_height="48dp" 
       android:visibility="invisible" 
       app:layout_collapseMode="pin"/> 
     </android.support.design.widget.CollapsingToolbarLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:layout_gravity="bottom" 
      android:orientation="vertical"> 

      <View 
       android:layout_width="wrap_content" 
       android:layout_height="0.4dp" 
       android:background="?attr/separate_line_color"/> 

      <android.support.design.widget.TabLayout 
       android:id="@+id/tablayout_user" 
       android:layout_width="match_parent" 
       android:layout_height="48dp" 
       android:layout_marginEnd="8dp" 
       android:layout_marginRight="8dp" 

       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintRight_toRightOf="parent" 
       app:layout_constraintTop_toBottomOf="@+id/view_line" 
       app:layout_scrollFlags="enterAlways" 
       app:tabGravity="center" 
       android:background="?attr/common_bg_white_black" 
       app:tabIndicatorColor="@color/theme_color" 
       app:tabIndicatorHeight="2dp" 
       app:tabMaxWidth="0dp" 
       app:tabMode="fixed" 
       app:tabPaddingEnd="20dp" 
       app:tabPaddingStart="20dp" 
       app:tabSelectedTextColor="@color/theme_color" 
       app:tabTextAppearance="@style/TabTextAppearance2" 
       app:tabTextColor="?attr/text_color_2"/> 

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

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

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