简体   繁体   中英

Can't scroll childview of scrollview while scrollview momentum is active

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM