Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RTL - Does android:autoMirrored work with png images?

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?

like image 350
RandomUser Avatar asked Jun 19 '17 18:06

RandomUser


People also ask

What is RTL support in android?

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.

How to set RTL in android?

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.


1 Answers

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>
like image 160
Benito Bertoli Avatar answered Oct 18 '22 03:10

Benito Bertoli