Automatically mirror the ImageView's src or View's background in the RTL layout direction.
Add app:mirrorSrc="true"
or app:mirrorBackground="true"
in xml files, resource's drawable will be auto mirrored. No need for extra mirror image files in ldrtl directory.
<ImageView
...
android:src="@mipmap/ic_launcher_round"
app:mirrorSrc="true" />
<TextView
...
android:background="@drawable/bg_chat"
app:mirrorBackground="true" />
Don't forget init this library in application. RtlImageLibrary.inject(this)
class RtlApplication : Application() {
override fun onCreate() {
super.onCreate()
RtlImageLibrary.inject(this)
}
}
- Add the JitPack repository to your build file
// Gradle < 6.8, root build.gradle file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
// Gradle >= 6.8 settings.gradle file
dependencyResolutionManagement {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency
dependencies {
implementation 'com.github.qiantao94:AndroidAutoRtlImage:0.0.1'
}
If you have custom view, this library's key code is drawable.setAutoMirrored(true)
, use it!
May conflict with other libraries that use LayoutInflater.Factory2