0

I am coding a multi language application one of those languages is Arabic that when selected I want to RTLize everything even the drawer fragment programmatically, please find below the layout xml:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/container_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:orientation="vertical">

        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />
    </LinearLayout>

    <FrameLayout
        android:id="@+id/container_body"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >


    </FrameLayout>


</LinearLayout>


<fragment
    android:id="@+id/fragment_navigation_drawer"
    android:name="com.customview.albertaadm.testapplication.FragmentDrawer"
    android:layout_width="@dimen/nav_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:layout="@layout/fragment_navigation_drawer"
    tools:layout="@layout/fragment_navigation_drawer" />

So I managed to RLT the actionbar and whole buttons but using the following code:

if (Lang.equals("ar")) {
        rtlizer = new ActionBarRtlizer(this, "toolbar");
        ViewGroup actionBarView = rtlizer.getActionBarView();
        ViewGroup homeView = (ViewGroup) rtlizer.findViewByClass("HomeView", actionBarView);
        rtlizer.flipActionBarUpIconIfAvailable(homeView);
        RtlizeEverything.rtlize(actionBarView);
        RtlizeEverything.rtlize(homeView);

but how can I make the fragment_navigation_drawer to re-position on the right and get it open to the right? Thank you.

Albert
  • 324
  • 1
  • 4
  • 20

1 Answers1

1

You can achieve it by adding android:supportsRtl="true" to the <application> element in your manifest file. but the problem with this is Native RTL support comes only after Android 4.2. If your app supporting before 4.2 then RTL will not work. More info:- http://android-developers.blogspot.in/2013/03/native-rtl-support-in-android-42.html

Adarsh Yadav
  • 3,752
  • 3
  • 24
  • 46
  • Hello, I managed to RTL for the devices before 4.2 my main problem is with the fragment drawer I want when I flip the view to make it reposition on the right and open to the left... – Albert Aug 03 '15 at 06:11
  • Have a look at this answer http://stackoverflow.com/a/19358114/1384010, like in this answer try to set gravity to your listview . – Adarsh Yadav Aug 03 '15 at 06:21
  • Hello, it's not a listView it's a Fragment – Albert Aug 03 '15 at 08:45