2016-09-28 13 views
2

私はAndroidプログラムを作成しています。このプログラムでは、ScrollView内部にRecyclerViewがあります。私はこのRecyclerViewにRecyclerViewAdapterを介してデータを追加しています。Recyclerビュー内のNestedScrollviewはスクロールしません

RecyclerViewの各項目には、垂直方向のLinearLayoutが1つあるNestedScrollviewがあります。私はこのLinearLayoutでImageViewを動的に追加しています。

問題は、画像がスクロールしていないことです。非常にまれなシナリオでは(画面上で何回もタップすることによって)、一度スクロールしました。

誰でも私にこれを助けることができますか?ここで

はコードがある -

親リサイクラービュー: -

<ScrollView 
    android:id="@+id/scroll_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    > 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     > 
    <android.support.v7.widget.RecyclerView 
     android:id="@+id/id_recyclerview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:divider="@color/gray3" 
     android:dividerHeight="5sp" 
     android:paddingLeft="2sp" 
     android:paddingTop="5sp" 
     android:paddingRight="2sp"/> 
     <com.app.sh.widget.WrappedGridView 
      android:id="@+id/gridView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@color/White" 
      android:numColumns="2"> 

     </com.app.socialhand.widget.WrappedGridView> 

    </LinearLayout> 
</ScrollView> 

そしてリサイクラービューのアイテム: -

<android.support.v4.widget.NestedScrollView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/vScrollView" 
       android:layout_below="@id/iv_up" 
       android:layout_above="@+id/iv_down" 
       android:isScrollContainer="true" 
       > 
       <RelativeLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"> 
       <LinearLayout 
        android:id="@+id/ll_123" 
        android:orientation="vertical" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        > 

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

私は動的にll_123でImageViewsを追加しています。

答えて

0

ScrollViewではなくNestedScrollViewを使用するか、削除してみてください。 RecyclerViewにはScrollViewと競合する独自のscrollviewがあります。

<ScrollView> 
    <NestedScrollView> 
     <LinearLayout> 
      <RecyclerView/> 
     </LinearLayout> 
    </NestedScrollView> 
</ScrollView> 

とのListItemのレイアウトが含まれている必要があります:あなたが好きな構造を試すことができます

+0

ネストされたScrollViewも試しましたが、まだ動作していません。スクロールビューがなければ、リサイクラビューはスクロールしません。 –

+0

あなたのコードを表示できますか? – giffell

+0

こんにちはgiffell、私はコードを追加しました。 –

0

これが正しく動作するかどうか

<NestedScrollView> 
    <LinearLayout/> 
</NestedScrollView> 

チェック...

+0

お返事ありがとうございました。しかし、ロジックは私のために働いていません。 –

0

私はsimmilar問題を持って、これが助けました私:

<ScrollView 
    android:id="@+id/messages_scroll" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/send_panel" 
    android:fillViewport="true" 
    android:padding="5dp"> 

    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:id="@+id/messages" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginTop="5dp" 
      android:animateLayoutChanges="true" 
      android:gravity="center_horizontal|bottom" 
      android:orientation="vertical"> 

     </LinearLayout> 
    </RelativeLayout> 
</ScrollView> 
+0

リサイクラーのアイテムのレイアウトをコードごとに変更しましたが、機能しません。 NestedScrollViewではなくScrollViewとしてリサイクラのアイテムを作成すると、親リストはスクロールして子リストをスクロールし始めます。 –

0
<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <-only one layout in nestade layout-> 

    <LinearLayout 
     android:id="@+id/activity_edit_existing_location" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/rcl" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"/> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

     <-put here yr second layout code-> 


     </RelativeLayout> 
    </LinearLayout> 
</android.support.v4.widget.NestedScrollView> 
+0

あなたの提案コードmadhavを取得できませんでした。それをもっと詳しく説明できますか? –

関連する問題