RTL-android:autoMirrored是否可以处理png图像?

Zug*_*dud 3 android internationalization

我读到从4.4开始,android支持自动镜像:

在早期版本的Android上,如果您的应用程序包含的图像应按从右到左的布局反转其水平方向,则必须将镜像图像包括在drawables-ldrtl /资源目录中。现在,通过在可绘制资源上启用autoMirrored属性或调用setAutoMirrored(),系统可以为您自动镜像图像。启用后,当布局方向从右到左时,Drawable将自动镜像。

链接:

https://developer.android.com/about/versions/android-4.4.html

这仅适用于矢量图形吗?还是可以与png文件等位图一起使用?

android:autoMirrored属性:

https://developer.android.com/reference/android/graphics/drawable/VectorDrawable.html

我的问题是,如果我将left-arrow.png嵌入资源作为我的应用程序中的资源,我可以以某种方式为我的图像定义此autoMirrior属性,以便当用户设备设置为rtl语言时,android将动态地对其进行反转。这可能吗?如果是这样,如何配置png图像的属性?

Ben*_*oli 8

您可以将可绘制对象包装到bitmap资源中

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/left-arrow"
    android:autoMirrored="true">
</bitmap>
Run Code Online (Sandbox Code Playgroud)