Подтвердить что ты не робот

Установите LayoutDirection (RTL) для api ниже 17

Я собираюсь построить Persian app (RTL). мое приложение включает в себя ListView и навигационный ящик ,

Я добавил в Manifest в теге приложения android:supportsRtl="true"

и в onCreate(): getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);

Я знаю, что LayoutDirection для менее чем 17 api не работает.

для уровня api 17 и выше:

enter image description here

для api ниже 17:

enter image description here

Как решить эту проблему. 1- Ввод conditional statement для проверки арифметики android и назначение определенного макета? 2-используемая папка layout-ldrtl в eclipse? 3 -...? Каков наилучший способ?

<android.support.v4.widget.DrawerLayout

       xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@+id/drawer_layout"


    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/myback">



<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="40dp"  >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginLeft="60dp"
        android:layout_marginRight="60dp"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="20dp" >




        <EditText
        android:id="@+id/edtxtsearch"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:layout_gravity="center_horizontal"
         android:hint="عبارت مورد جستجو"
          android:textSize="13dp"
         >

        <requestFocus />
    </EditText> 


        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_gravity="center"

            >


            <ListView
                        android:id="@+id/mylist"
                        android:layout_width="200dp"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center_horizontal"
                      android:divider="@android:color/transparent"
                      android:dividerHeight="7dp"
                      android:scrollbarStyle="outsideInset"
                      />



           </LinearLayout>



</LinearLayout>




<FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

         >



    </FrameLayout>



     <ListView
        android:id="@+id/list_slidermenu"
        android:layout_width="240dp"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:background="#ffffff"
        android:dividerHeight="4dp"  
         android:divider="@android:color/transparent"     

       />

    </android.support.v4.widget.DrawerLayout>
4b9b3361

Ответ 1

используйте ViewCompat из android.support.v4.view.ViewCompat!

:

ViewCompat.setLayoutDirection (View yourView, int layoutDirection)

layoutDirection является константой класса ViewCompat