How to create a layout for RTL

Enes Varol
2 min readJun 1, 2022

--

Photo by sebastiaan stam on Unsplash

When it comes to LTR and RTL support, android has multiple ways to achieve the support that we want.

For example:

  • android: layoutDirection
  • android: autoMirrored
  • android: supportRtl

However,

These might not give the result that we want.

In my case:

I couldn’t find a way to give a mirror effect to ShapeableImageView’s ShapeAppereanceOverlay.

Then creating a layout for RTL comes into play.

How to do it?

In my case:

1- I created a directory with the name “layout-ldrtl” in the res folder.

ldrtl: Layout direction right to left

2- Then I cloned my layout to that folder and used a different ShapeApperanceOverlay for my ShapeableImageView.

3- Build and run.

Result: Android selects the correct layout file automatically for us.

Conclusion

I explained how to use a different layout for RTL. However, for the consistency of the screens: Keep the layouts similar as much as you can.

Photo by Jan Tinneberg on Unsplash

References

1- Supporting RTL Design on Android

2- RTL Support on Andorid. Here is all you need to now

--

--