Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to display scroll bar on the left for right-to-left layouts? #70

Closed
MinaHany opened this issue Dec 4, 2016 · 14 comments
Closed

How to display scroll bar on the left for right-to-left layouts? #70

MinaHany opened this issue Dec 4, 2016 · 14 comments

Comments

@MinaHany
Copy link

MinaHany commented Dec 4, 2016

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?

@turing-tech
Copy link
Owner

I've been a bad developer and avoided coding it :P I can do it tomorrow though.

@MinaHany
Copy link
Author

MinaHany commented Dec 4, 2016

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!

@MinaHany
Copy link
Author

MinaHany commented Dec 5, 2016

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 :)

@turing-tech
Copy link
Owner

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.

@MinaHany
Copy link
Author

MinaHany commented Dec 5, 2016

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

@turing-tech
Copy link
Owner

I'm doing it right now actually. I'll have it in a few minutes.

@MinaHany
Copy link
Author

MinaHany commented Dec 6, 2016

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 :)

@MinaHany
Copy link
Author

MinaHany commented Dec 6, 2016

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:

screenshot_1481016341

@turing-tech
Copy link
Owner

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.

@MinaHany
Copy link
Author

MinaHany commented Dec 7, 2016

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:

capture

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?

@turing-tech
Copy link
Owner

Just to clarify, what's the system direction during this time? Is the isRTL function asking about an in app setting?

@MinaHany
Copy link
Author

MinaHany commented Dec 7, 2016

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.

@turing-tech
Copy link
Owner

turing-tech commented Dec 8, 2016

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.

@MinaHany
Copy link
Author

MinaHany commented Dec 8, 2016

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants