RTL support in ImageButton with autoMirror for src drawable

When creating an ImageButton with android:background="?android:attr/selectableItemBackground"and android:src="@drawable/ic_action_send"adding android:autoMirror="true"has no disgusting effect. Is there a way to easily support right-to-left (RTL) image mirroring on ImageButtons?

+4
source share
1 answer

Make an XML drawing and install android:autoMirrored="true". This value is ignored before 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"/>

Now use android:src="@drawable/icon_auto_mirroredin your layout.

+8
source

All Articles