Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android RTL layout Direction behavior

Tags:

android

I change my layoutDirection to RTL, but in both RTL and LTR direction getX() method return the same number. this method calculate X from left side of screen. How can I change the behavior of the layout to calculate X from the right of the screen ? thanks alot.

like image 835
BaBaX Ra Avatar asked Feb 03 '26 20:02

BaBaX Ra


1 Answers

View system in android works independently from layout directions! which means ,in your case and any others cases, it works properly and calculates X and Y from top-left of the screen!

for your problem there is two approaches :

one calculate x from right of the screen with like below pseudo

screenWidth - getX()

two reverse your code to work with real X.

like image 199
hamidrezabstn Avatar answered Feb 06 '26 10:02

hamidrezabstn