2016-12-23 3 views
3

内Horizo​​ntalScrollViewこの私のlayout.xmlです。 最初のリストビューはlist_viewです。 2番目のリストビューはLinearLayout(nest_list_view_container)に動的に追加されます。Horizo​​ntalScrollView内のListViewコントロールとScrollView

setOnTouchListenerメソッドでは最初のListViewは正常に動作しますが、2番目のListViewは同じメソッドでスクロールできず、クリックイベントにのみ応答します。

+0

は、あなたがこのリンクを確認しました:https://trivedihardik.wordpress.com/2011/09/19/scrollview-inside-scrollview-scrolling-problem/ –

+0

@MavyaSoniはい、それはdoesnのです仕事はありません。 – LiXinShen

答えて

1

使用recyclerviewの代わりに、リストビューとスムーズrecyclerviewを移動することで、このコードを使用します。

  android:nestedScrollingEnabled="false" 

も、私が使用することを好む:このような状況で

 <android.support.v4.widget.NestedScrollView 
      android:id="@+id/activity_Recipe_detail_scrollview" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical"> 
        // .. 
      </LinearLayout> 
     </android.support.v4.widget.NestedScrollView> 

+0

ありがとうございました。あなたの提案は非常に便利です。しかし、アンドロイド:nestedScrollingEnabled = "true"は私のために働いた。 – LiXinShen

0

ScrollView.ListView内でListViewを保持しないでください。動的に更新されているリストにスクロール可能です。ListViewの上にあるViewGroupをすべて削除してもう一度やり直してください。

+1

nestedScrollView @ujjwal – tahaDev

1

それは間違いですスクロールビュー の中にlistviewやrecyclerviewを追加することができます。これは私のプロジェクトで何度も使用されています。 例:

<android.support.v4.widget.NestedScrollView 
      android:id="@+id/activity_Recipe_detail_scrollview" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

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

        <android.support.v7.widget.CardView 
         android:id="@+id/activity_Recipe_detail_hashtag_card" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginBottom="@dimen/recipe_detail_card_margin_top" 
         android:layout_marginLeft="32dp" 
         android:layout_marginRight="32dp" 
         android:layout_marginTop="@dimen/recipe_detail_card_margin_top" 
         app:cardBackgroundColor="@android:color/white" 
         app:cardCornerRadius="@dimen/radius_recipe_detail_card" 
         app:cardElevation="1dp" 
         app:contentPadding="16dp"> 

         <android.support.v7.widget.RecyclerView 
          android:id="@+id/activity_Recipe_detail_hashtag_list" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          tools:listitem="@layout/hashtag" /> 
        </android.support.v7.widget.CardView> 

       </LinearLayout> 
      </LinearLayout> 
     </android.support.v4.widget.NestedScrollView> 
関連する問題