2016-08-22 6 views
0

スクロール可能な別のビュー内にスクロール可能なビューを追加することは推奨されませんが、この要件は変更できません。 私はLinearLayoutManagerの向きがHorizo​​ntalである通常のRecylerViewを持っています。水平RecylerView内のHorizo​​ntalScrollViewがスクロールしない

LinearLayoutManager manager2 = new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL, false); 
rec_products.setLayoutManager(manager2); 

それは、アダプタ

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="400dp" 
    android:layout_height="wrap_content" 
    android:background="@color/productblue" 
    android:layout_marginLeft="20dp" 
    android:layout_marginRight="20dp" 
    android:orientation="vertical"> 



    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/icon_abc" 
     android:scaleType="fitXY"/> 


    <HorizontalScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:weightSum="5"> 

      <LinearLayout 
       style="@style/products_item_options" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:orientation="vertical"> 

       <ImageView 
        android:layout_width="@dimen/product_layout_icon_size" 
        android:layout_height="@dimen/product_layout_icon_size" 
        android:layout_gravity="center" 
        android:src="@drawable/icon_cart_new"/> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginTop="5dp" 
        android:gravity="center" 
        android:text="Add" 
        android:textColor="@android:color/black"/> 
      </LinearLayout> 

      <LinearLayout 
       style="@style/products_item_options" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:orientation="vertical"> 

       <ImageView 
        android:layout_width="@dimen/product_layout_icon_size" 
        android:layout_height="@dimen/product_layout_icon_size" 
        android:layout_gravity="center" 
        android:src="@drawable/icon_cart_new"/> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginTop="5dp" 
        android:gravity="center" 
        android:text="Color Option" 
        android:textColor="@android:color/black"/> 
      </LinearLayout> 

      <LinearLayout 
       style="@style/products_item_options" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:orientation="vertical"> 

       <ImageView 
        android:layout_width="@dimen/product_layout_icon_size" 
        android:layout_height="@dimen/product_layout_icon_size" 
        android:layout_gravity="center" 
        android:src="@drawable/icon_emailquotegray"/> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginTop="5dp" 
        android:gravity="center" 
        android:text="Email Quote" 
        android:textColor="@android:color/black"/> 
      </LinearLayout> 

      <LinearLayout 
       style="@style/products_item_options" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:orientation="vertical"> 

       <ImageView 
        android:layout_width="@dimen/product_layout_icon_size" 
        android:layout_height="@dimen/product_layout_icon_size" 
        android:layout_gravity="center" 
        android:src="@drawable/icon_brochureemailgray"/> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginTop="5dp" 
        android:gravity="center" 
        android:text="Email Brochure" 
        android:textColor="@android:color/black"/> 
      </LinearLayout> 

      <LinearLayout 
       style="@style/products_item_options" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:orientation="vertical"> 

       <ImageView 
        android:layout_width="@dimen/product_layout_icon_size" 
        android:layout_height="@dimen/product_layout_icon_size" 
        android:layout_gravity="center" 
        android:src="@drawable/icon_brochureemailgray"/> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginTop="5dp" 
        android:gravity="center" 
        android:text="Check Stock" 
        android:textColor="@android:color/black"/> 
      </LinearLayout> 

     </LinearLayout> 

    </HorizontalScrollView> 
</LinearLayout> 

アダプタで行わ何も特別な、普通のviewholderインフレとの結合に膨張された内部のカスタムビューを持っています。 水平スクロールビューがスクロールしていません。これを修正するにはどうすればよいですか?

+0

は、水平スクロールビューの幅を修正:

がRecyclerView水平リストを作成するには、このような何かを行う可能性があります。 – Ramit

+0

@Ramitはまだ動作しません –

答えて

0

RecyclerViewを使用する場合は、ビュー内の各項目のレイアウトを担当するLayoutManagerを指定する必要があります。 LinearLayoutManagerを使用すると、通常のLinearLayoutと同様に方向を指定できます。

LinearLayoutManager layoutManager 
= new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); 

RecyclerView myList = (RecyclerView) findViewById(R.id.my_recycler_view); 
myList.setLayoutManager(layoutManager); 
+0

リサイクラビューに水平スクロールVIEWを指定する必要はありません。 – Athul

+0

リサイクル業者を初期化し、私が言及したコードを追加してください – Athul

+0

私はリサイクラー・ビューを作成して、あなたのサイトで活動を開始することを意味します。メインアクティビティ – Athul

関連する問題