ImageButton 的 RTL 支持,带有 autoMirror for src drawable
RTL support on ImageButton with autoMirror for src drawable
使用 android:background="?android:attr/selectableItemBackground"
和 android:src="@drawable/ic_action_send"
创建 ImageButton 时,添加 android:autoMirror="true"
没有任何明显的影响。有什么方法可以轻松支持 ImageButtons
上的从右到左 (RTL) 图像镜像?
创建一个 XML 可绘制对象并设置 android:autoMirrored="true"
。 API 19.
之前这个值被忽略
res/drawable/icon_auto_mirrored.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/icon"
android:autoMirrored="true"/>
现在在您的布局中使用 android:src="@drawable/icon_auto_mirrored
。
将rotationY
添加到ImageView
:
< ImageView ... android:rotationY="@integer/rtl_mirror_flip"
将 rtl_mirror_flip
声明为 0(对于 ltr)或 180(对于 rtl):
<整数名称="rtl_mirror_flip">0
要么
<整数名称="rtl_mirror_flip">180< /integer>
使用 android:background="?android:attr/selectableItemBackground"
和 android:src="@drawable/ic_action_send"
创建 ImageButton 时,添加 android:autoMirror="true"
没有任何明显的影响。有什么方法可以轻松支持 ImageButtons
上的从右到左 (RTL) 图像镜像?
创建一个 XML 可绘制对象并设置 android:autoMirrored="true"
。 API 19.
res/drawable/icon_auto_mirrored.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/icon"
android:autoMirrored="true"/>
现在在您的布局中使用 android:src="@drawable/icon_auto_mirrored
。
将
rotationY
添加到ImageView
:< ImageView ... android:rotationY="@integer/rtl_mirror_flip"
将
rtl_mirror_flip
声明为 0(对于 ltr)或 180(对于 rtl):<整数名称="rtl_mirror_flip">0 要么 <整数名称="rtl_mirror_flip">180< /integer>