Android Question AppCompat with ToolBar RTL Direction

Peter Simpson

Expert
Licensed User
Can anyone please guide me how to use https://www.b4x.com/android/forum/threads/appcompat-with-toolbar-minimal-example.79896/
with RTL support ? I need to display the burger icon on the right and the menu to appear from right.
Have you looked at the app compat (Material Design) library?
https://www.b4x.com/android/forum/threads/appcompat-make-material-design-apps-compatible-with-older-android-versions.48423/

Also look at this.
https://www.b4x.com/android/forum/threads/msmaterialmenu-animating-icons.44735/

Maybe this.
https://www.b4x.com/android/forum/threads/materialdrawer-v0-9-mike-penz.74410/#content

There's too much to look for, just search the forum for 'MaterialDrawer'...
 

samikinikar

Member
Licensed User
Thank you so much for your support, but I could not find the burger icon and text right aligned option, I was able to get the navigationdrawer from right by changing the code to sm.Mode = sm.left to sm.right. Is there any similar way to change the burger icon and text to appear at the right ? I mean for RTL apps
 

samikinikar

Member
Licensed User
Add SetApplicationAttribute (android:supportsRtl, true) to manifest.
Default language in phone Settings should be also RTL.
Thank you so much.....but there is no change in my output, the reason is my default language is not RTL.

Is there any way to make it RTL layout without changing the phone settings ?
 

Semen Matusovskiy

Well-Known Member
Licensed User
Default language defines current locale for application.
Most multi-language applications simply read settings and use appropriate resources. For example:
B4X:
    Dim jo As JavaObject
    jo.InitializeStatic ("java.util.Locale")
    Log (jo.RunMethodJO ("getDefault", Null).RunMethod ("getISO3Language", Null))
    Log (jo.RunMethodJO ("getDefault", Null).RunMethod ("getDisplayLanguage", Null))
Of course, Android offers a way to set locale in run-time. But it's not for lazy due to permanent changes in API.
For example
https://github.com/gunhansancar/ChangeLanguageExample/blob/bbb0f4b21af49a7978721f7dee878361a8d19400/app/src/main/java/com/gunhansancar/changelanguageexample/helper/LocaleHelper.java

Well, I did small library and sample (attached). They more or less work, but require some corrections, first of all, for API 26+. Probably, tomorrow evening I will clean a project.
 

Attachments

Last edited:

samikinikar

Member
Licensed User
Default language defines current locale for application.
Most multi-language applications simply read settings and use appropriate resources. For example:
B4X:
    Dim jo As JavaObject
    jo.InitializeStatic ("java.util.Locale")
    Log (jo.RunMethodJO ("getDefault", Null).RunMethod ("getISO3Language", Null))
    Log (jo.RunMethodJO ("getDefault", Null).RunMethod ("getDisplayLanguage", Null))
Of course, Android offers a way to set locale in run-time. But it's not for lazy due to permanent changes in API.
For example
https://github.com/gunhansancar/ChangeLanguageExample/blob/bbb0f4b21af49a7978721f7dee878361a8d19400/app/src/main/java/com/gunhansancar/changelanguageexample/helper/LocaleHelper.java

Well, I did small library and sample (attached). They more or less work, but require some corrections, first of all, for API 26+. Probably, tomorrow evening I will clean a project.
Great Work.... Thank you so much.
 
Top