private fun setLocale(lang: String) {
val language = Locale(lang)
val res: Resources = resources
val dm: DisplayMetrics = res.displayMetrics
val conf: Configuration = res.configuration
conf.locale = language
res.updateConfiguration(conf, dm)
val refresh = Intent(this, LoginActivity::class.java)
startActivity(refresh)
finish()
}
Hello Everybody!
I'm creating an android app and this is for Arabic people. And I have created the string resources for "en" and "ar" xml and declared it in Mainfest.xml android:supportsRtl="true"
.
When I use this code to convert app language, it converts the texts ONLY. Without converting the layout direction, text direction and text alignment.
- This code contains
.locale
and.updateConfiguration
as java code. Can you please to help me how to cleanup whole code to be suitable for kotlin code? - Can you please to help me solve RtL problem to make the app more professional and accuracy app?