I read that since 4.4, android supports autoMirroring:
On previous versions of Android, if your app includes images that should reverse their horizontal orientation for right-to-left layouts, you must include the mirrored image in a drawables-ldrtl/ resource directory. Now, the system can automatically mirror images for you by enabling the autoMirrored attribute on a drawable resource or by calling setAutoMirrored(). When enabled, the Drawable is automatically mirrored when the layout direction is right-to-left.
Link:
https://developer.android.com/about/versions/android-4.4.html
Does this only work for vector graphics, or can it also be used with bitmaps like png files?
Attribute android:autoMirrored:
https://developer.android.com/reference/android/graphics/drawable/VectorDrawable.html
My Question is, if I embedded left-arrow.png as a resource in my app, could I somehow define this autoMirrior property for my image so that when the users device is set to an rtl language android will invert it dynamically. Is this possible? If so, how do I configure the property of a png image?
A class for defining layout directions. A layout direction can be left-to-right (LTR) or right-to-left (RTL). It can also be inherited (from a parent) or deduced from the default language script of a locale.
In your android phone, tap on “Settings” icon. Now tap on developer options and search for “Force RTL layout direction”. Tap on it to enable RTL feature.
You can wrap your drawable in a bitmap
resource
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/left-arrow"
android:autoMirrored="true">
</bitmap>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With