android: flip a layout without flipping the content inside it

1.7k views Asked by At

I am making an android app, which supports two languages (Arabic and English)
and as you already know that the English script reads from left to right, while Arabic script reads from right to left. This requires me to, if I change the language, to flip the layout without flipping the component to keep it visible and readable as before like images and texts.

Thank you

4

There are 4 answers

0
Asif Rahman On BEST ANSWER

In this case flipping view is not the right approach, android has built-in support for different languages for example Arabic which starts from Right to Left, so you have to use RTL for showing Arabic properly.

Check out these links for better understanding:

  1. https://developer.android.com/training/basics/supporting-devices/languages
  2. https://medium.com/@zhangqichuan/rtl-support-in-android-898e11f31561
0
AudioBubble On

If I didn't understand wrong, you should change the gravity of textView on your changing language method. For an example

TextView textView = (TextView) findViewById(R.id.textView); textView.setGravity(Gravity.RIGHT | Gravity.CENTER);
0
BlackGraper On

I have a linear layout oriented horizontally like the sample image below illustrates
and changing only the gravity doesn't fix the issue I guess.
Sample Image

0
BlackGraper On

I already have and idea about how to fix it, and its a tough process.
The thing is to change the attribute
android:scaleX="-1f"
and make this change to the ViewGroup and every single View inside it.