1

I Have the following View:

 _____________________________ 
| ___________________________ |-- ScrollView
|| _________________________ ||-- Vertical Linear Layout
||| _______  ______________ |||-- Horizontal Linear Layout
|||| ListA || RecyclerView ||||
||||  Head ||  <========>  ||||
||||_______||______________||||
|||_________________________|||
|| _________________________ ||
||| _______  ______________ |||
|||| ListB || RecyclerView ||||
||||  Head ||  <========>  ||||
||||_______||______________||||
|||_________________________|||
||  /\                       ||  
||  ||   LinearLayout        ||
||  \/                       ||
||___________________________||
|_____________________________|  

The Linear layout should scroll vertically and the RecyclerView's should independently from each other scroll horizontally when touched and scrolled inside them.

This already works mostly fine.But I have two problems.

1) When I touch down on one View (RecyclerView or ScrollView) only this view will get all scroll events until I release the finger again. So when I scroll right in the RecyclerView I can't scroll up and down in the ScrollView simultaneously. This behaviour is ok'ish but would love to test how it feels if I could scroll both views simultaneously.

2) Bigger problem: As long as the ScrollView keeps scrolling after releasing the finger due to momentum, I can't start scrolling the child RecyclerViews as even a new touch event above the RecyclerView is still caught by the ScrollView.

So how can I get rid of the behaviour in 2) ?

UPDATE:

The buttons on the left should stay visible when the RecyclerView is scrolled horizontally.

I know that I could solve this with a big RecyclerView having all elements in it, But it would be quite complex. As each recyclerView content should scroll independently and the buttons on the left should stay visible unless scrolled vertically outside of view.

Is there maybe a possibility to prevent the momentum scrolling of the ScrollView or to immediately stop it on the next touch? Or can I pass the scrollevents to the childView so both views can act upon it?

Update 2: Updated the example with missing Horizontal Linear Layout

Torge
  • 2,174
  • 1
  • 23
  • 33

2 Answers2

0

Either you use a NestedScrollView or you implemented your LinearLayout into your RecyclerView as "Footer". Then you can completely delete the ScrollView and just use the RecyclerView.

To put the LL into your RV you have to declare several ViewTypes with one ViewHolder for each different ViewType.

matt.mic
  • 185
  • 1
  • 1
  • 12
  • I just tried. But simply replacing ScrollView by android.support.v4.widget.NestedScrollView does not seem sufficient. No change in behaviour – Torge Jan 24 '17 at 12:49
  • try the approach with different ViewTypes :) – matt.mic Jan 24 '17 at 12:52
  • I really would like to avoid that if possible I've been to that hell already for my EPG grid. So this is last resort. But thx. – Torge Jan 24 '17 at 13:04
0

change LinearLayout from scrollview to outside recyclerview not need to scrollview only LinearLayout put inside recycleview

either check this link : https://stackoverflow.com/a/6211286/4427519

Community
  • 1
  • 1
Dhara Patel
  • 359
  • 5
  • 19
  • Did you take into account that the buttons on the left should stay visible when a RecyclerView is scrolled horizontally. If I simply put the linear layout insid the RecyclerView it would scroll outside of view without extra effort. – Torge Jan 24 '17 at 13:12
  • if you need button in every position then why u r not adding button in recyclerview raw file(cardview) – Dhara Patel Jan 24 '17 at 13:26