Seven
Seven

Reputation: 1

RecyclerView in NestedScrollView with horizontal-scolling

I want to result like this:

enter image description here

which can do horizontal-scrolling.

But in fact, like this below:

enter image description here

Which can't display all item and not horizontal-layout.

who can help me ? thanks. other way can reach my wanted result here?

Upvotes: -2

Views: 958

Answers (2)

Abdul Rizwan
Abdul Rizwan

Reputation: 4108

To set recyclerView as horizontal scrollView you can use LinearLayoutManager. by default it sets vertical scroll behaviour.

LinearLayoutManager layout = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);//0 Horizontal , 1 vertical
recyclerView.setLayoutManager(layout);

in layout.xml

<android.support.v7.widget.RecyclerView
    android:id="@+id/yourRecyclerView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/layout_past_round_header"
    android:layout_centerInParent="true"
    android:overScrollMode="never" />

in your NestedScrollView add this

android:fillViewport="true"

Upvotes: 0

Sanjeet
Sanjeet

Reputation: 2403

You need to add Layout manager to RecylerView.

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
    recylcerView.setLayoutManager(layoutManager);

This will make the RecylerView horizontal.

Upvotes: 0

Related Questions