2017-07-24 20 views
0

ich habe dieses Layout>RecyclerView Innenansicht-Pager in einem Scrollview

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:fillViewport="true"> 

     <LinearLayout 
      android:id="header_content" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      > 
      <android.support.v7.widget.RecyclerView 
       android:id="@+id/moods_recyclerview" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0" 
       android:scrollbars="none" /> 

      <android.support.v4.view.ViewPager 
       android:id="@+id/mainwindow_view_pager" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" /> 
     </LinearLayout> 

    </ScrollView> 


    <android.support.design.widget.TabLayout 
     android:id="@+id/mainwindow_tab_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0" 
     android:background="@drawable/view_border_top" /> 
</LinearLayout> 

Ein d ViewPager Fragment haben diesen Code

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/net_rclerview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="none" 
     android:layout_weight="0" 
     android:layout_marginTop="10dp" 
     android:layout_marginBottom="10dp"/> 
</LinearLayout> 

i die

header_content Layout wollen

gescrollt werden, wenn der

net_rclerview innerhalb des View-Pager Fragment

gescrollt wird. Das Problem ist Recyclerview ist Scrollen, aber der obige Inhalt scrollt nicht aus der Sicht, ist das möglich zu erreichen und wenn es irgendwelche anderen Optionen, die ich tun kann?

+0

make RecyclerView.setNestedScrollingEnabled (false); –

+0

@NileshRathod funktioniert nicht :( –

+0

Haben Sie eine Lösung für dieses Problem gefunden? –

Antwort

1

Verwendung NestedScrollView statt ScrollView

<android.support.v4.widget.NestedScrollView 
      android:id="@+id/nestedScrollingView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fillViewport="true" 
      android:fitsSystemWindows="true" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

und

RecyclerView.setNestedScrollingEnabled(false);, um Ihr recyclerview

+0

es funktioniert nicht Mann –

+0

ich vergiss zu erwähnen, dass dieser Code in einem Haupt-Viewpager ist: MainWindow> Viewpager> ScrollView {Inhalt und Ansicht Pager} -> RecylereView –

0

Ich kam gerade über ähnliches Problem und nach vielen Surfen herausgefunden ich, dass Problem war nicht mit RecyclerView aber mit ViewPage r. Die WrapContent-Eigenschaft von ViewPager funktioniert nicht, wenn sie in ScrollView eingefügt wird. Eine feste Höhe schränkt RecyclerView ein, um den vollen Inhalt anzuzeigen. Aktualisiere die OnMeasure-Methode von ViewPager einfach wie folgt:

Es funktionierte für mich. Hoffe, es funktioniert auch für dich.

Verwandte Themen