Closed Mina-H-Samy closed 7 years ago
I've been a bad developer and avoided coding it :P I can do it tomorrow though.
so turns out I'm actually not going to use it in my project after all so no rush at all. But yeah would be useful nonetheless!
mm you know what I take that back, I will use it :P
But you don't have to do this yourself, if you give me a few pointers I can do it myself and create a PR :)
So I would actually do a refactor and remove the whole system of adding the scroll bar programatically and just have people add it in XML. I've been planning to do this and frankly it would just make things a lot simpler. If that's too complicated to do let me know and I can go ahead and do that bit.
After that you would need to use this solution to detect RTL layouts and then reverse all of the animation values where applicable. If you need help doing this too just let me know.
ok so is the refactor related to this? Since that would be a breaking change I imagine you would want to deprecate the programmatic way somehow before removing it completely?
Would it make sense to just do the RTL support now without the refactor?
Oh and I don't know if that solution is what I'm looking for... So sometimes the device's language is using a LTR language but it is only the text in my recyclerview that is RTL, and so I'd probably need a 'setRTL(boolean)' on the scrollbar
I'm doing it right now actually. I'll have it in a few minutes.
wow you're fast! And the new version is already released too! Thank you very much! A small donation coming your way - dinner's on me :)
so I just tested 11.2.0 and the right to left works beautifully! Except now I think the left to right is broken. If I setRightToLeft(false) or if I do not call that method at all, I still get the scroll bar on the left side but with the LTR drawable:
Holy crap, thanks! As far as the alignment goes, have you set alignParentRight to true? The bar won't align itself, so if you want it to operate in a LTR mode you need to set the bar up in the right side of the screen.
You mean alignParentRight on the DragScrollBar itself, yes?
I can't seem to be able get it to work correctly still. It looks like for RTL the indicator appears to the left of the screen (so it is off screen).
In the XML I have none of the layout_ params except height and width. And in the code I call setRightToLeft(isRTL)
and also:
With that setup, the LTR works fine, but the RTL, the indicator shows to the LEFT of the scrollbar (and the scrollbar itself is on the left, so the indicator is shown off-screen). I am using a the CustomIndicator() btw.
Here is how you can test if this works on your side: Have your phone locale in English, and display all English text in the RecyclerView. Now, are you able to get the scrollbar to show on the left and the right based on your code and not on your locale?
Just to clarify, what's the system direction during this time? Is the isRTL function asking about an in app setting?
yes just an app setting, I have itsuch that users can specify which language they want regardless of system locale. As in: I don't care what's the system direction, if my recyclerview is using a LTR language then I want scrollbar on the right, and on the left for RTL language.
So the ALIGN_PARENT_END rule is going to align based on the system detected locale. The library does not alter the layout of the bar at all. If the bar is appearing on the wrong side of the screen then that's an issue in the layout rules that the developer is using, not the library.
You should probably assign the ALIGN_PARENT_RIGHT or ALIGN_PARENT_LEFT rule and not have an END or START rule at all.
ah I found the culprit... It was that I had the DragScrollBar in a separate xml file and I was inflating it manually and adding it to the RelativeLayout (the recyclerview's parent). For some reason that caused the scrollbar to be erratic.
Anyway, works great now. I really appreciate you coding this up that fast, thanks very much!
Is there a way to display the scrollbar on the left hand side of the screen for right-to-left languages? Doesn't look like this is exposed through a public method so is it easy to override this in some other way?