0

I have a RecyclerView with Horizontal and Vertical scrolling. Because, This is a Grid, with recyclerview. Why? Because It's much optimalized than simple Grid in ScrollViews.

I want to add a Line to recyclerview. Above the items. (Z coordinate) enter image description here

This line need to scrolling with list items.

Anyone have idea how to do it? Can I add a new Layer above the items?

ketom
  • 2,334
  • 4
  • 17
  • 25

2 Answers2

1

I'd probably just add another view on top of the RecyclerView in the view hierarchy, add a ScrollListener to the RecyclerView and translate the line accordingly when the user scrolls.

<FrameLayout>

    <RecylerView
        ...
        />

    <View
        android:id="@+id/line"
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:background="#FF00FF"
        />

</FrameLayout>
patrick.elmquist
  • 2,113
  • 2
  • 21
  • 35
1

First of all create a vertical view like this : (in general the correct way is to declare the View first and position the list above this View) :

<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="@android:color/holo_blue_light" />

And then declare your <RecyclerView />

N.B: if you have to use a simple layout, then use FrameLayout is more efficient, else use RelativeLayout (larger and more capable than the much simpler FrameLayout)

serabile
  • 329
  • 3
  • 11
  • If I declare this view first, then it's behind the recycler. But It isn't scrolling with the recycler. – ketom Nov 22 '17 at 11:07