ImageButton上的RTL支持,带有用于src drawable的autoMirror

时间:2016-03-03 06:08:28

标签: android right-to-left

使用android:background="?android:attr/selectableItemBackground"android:src="@drawable/ic_action_send"创建ImageButton时,添加android:autoMirror="true"没有任何可辨别的效果。有没有办法轻松支持ImageButtons上的从右到左(RTL)图像镜像?

2 个答案:

答案 0 :(得分:13)

制作XML drawable并设置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

答案 1 :(得分:1)

  1. rotationY添加到ImageView中:

  2. rtl_mirror_flip声明为0(对于ltr)或180(对于rtl):

    <整数名称=“ rtl_mirror_flip”> 0 要么 180