I am making an app to show all product in 1 view. I want the recyclerview show all item and can not scroll, just scroll parent view( ScrollView ). But problem is can not make height of recycler wrap all content.
-->>I want like this
This is my code:
<TextView
android:text="Best seller:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView4"
android:textColor="#3f3f3f"
android:textSize="18sp" />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:scrollbars="horizontal"
android:id="@+id/rv_bestSeller"
android:layout_height="200dp" />
<TextView
android:text="New Product"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView5"
android:textSize="18sp"
android:textColor="#3f3f3f" />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:scrollbars="horizontal"
android:layout_height="200dp"
android:id="@+id/rv_newProduct"/>
<TextView
android:text="All Product"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView6"
android:textSize="18sp"
android:textColor="#3f3f3f" />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rv_allProduct" />
</LinearLayout>
</ScrollView>
-->>But the space is so small
You should use NestedScrollView
and setNestedScrollingEnabled(false)
combined.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With