turing-tech / MaterialScrollBar

An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.
Apache License 2.0
781 stars 126 forks source link

Reduce thickness of zone where TouchEvent's are intercepted #57

Closed BobOtike closed 8 years ago

BobOtike commented 8 years ago

First of all, this is a great library and thank you for making it.

I have a use case where the items in my RecyclerView feature a button on the right side to show a popupMenu. I already adjusted the thickness of the TouchScrollBar using setBarThickness so that it fits into the margin between the button's right edge and the screen's edge, but it still seems to intercept touches on my buttons. This lead me to the conclusion, that reducing the thickness only reduces the visible size of the TouchScrollBar but not the thickness of the zone where it actually intercepts TouchEvents.

Correct me if I'm wrong and if not: is there a way to reduce that thickness likewise?

Thanks in advance, cheers!

turing-tech commented 8 years ago

I just checked and it looks like you're right! That's my fault. I'll try and get that fixed for you today.

BobOtike commented 8 years ago

Thank you, I appreciate it and look forward to trying the fix.

turing-tech commented 8 years ago

Let me know how it works. If there's a problem I'll reopen.

BobOtike commented 8 years ago

Thanks for taking care of this this so fast!

The problem I described before is gone now, but another one has arisen:

I use a TouchScrollBar with autoHide = true and respondToTouchIfHidden = false. Before your fix, the ScrollBar would intercept the TouchEvents on the buttons while it was hidden, which is now not a problem anymore. I'm using barThickness = 25 and when the ScrollBar is not hidden, it is almost impossible to use it for scrolling since the area it reacts to touches in is so small. Maybe you can see for yourself with that value.

What first comes to mind as a solution would be to differentiate between hidden and not hidden state: when the ScrollBar is hidden it uses your fix but when visible it falls back to the original thickness to intercept TouchEvents.

I don't know if that is something you would implement, maybe that is too specific for my exact case, but I would love to hear your thought on that matter.

BobOtike commented 8 years ago

Hi @krimin-killr21,

have you given this issue some thought?

I noticed in the code that the OnTouchListener in the TouchScrollBar only returns false when the ScrollBar has been explicitly hidden by the user. IMHO it should also return false when hidden == true and respondToTouch == false.

It think it makes no sense to consume the TouchEvent when the ScrollBar isn't going to react to it. This way my issue would also be fixed. The buttons get all their TouchEvents when the ScrollBar is hidden and when it is not I can simply use a greater thickness to ensure it is easy to scroll.