Android – Disable ActionBar RTL Direction

androidandroid-layoutbidiright-to-left

Android 4.2 introduced RTL (BiDi) support, to start using it I just follow the instructions (android:supportsRtl attribute to the element in your manifest file and set it “true")

But then my ActionBar logo also changes orientation to the right (Logo is displayed on the right) which I don't want.
I do want to use the RTL features but keep the ActionBar oriented to the left…

In other word, how do I use the android:supportsRtl attribute without it changing the ActionBar direction on Android 4.2 when the language direction is RTL

Any suggestions ?

Best Answer

i had the same problem , only that i have a slidingMenu (AKA navigation drawer), so it got even weirder (meaning you click on the top right "up" button and show the drawer on the left...).

there are 2 possible solutions:

  1. by code , in each activity:

    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1)
        getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
    
  2. by theme. edit your own customized theme, and add the correct line. example:

    <style name="AppTheme" parent="@style/Theme.Sherlock.Light">
      <item name="actionBarStyle">@style/CustomActionBarStyle</item>
      <item name="android:actionBarStyle" tools:targetApi="honeycomb">@style/CustomActionBarStyle</item>
    </style>
    
    <style name="CustomActionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar">
      <item name="android:layoutDirection" tools:targetApi="jelly_bean_mr1">ltr</item>
    </style>
    
Related Topic