0
votes

I'm trying to support rtl view in a layout that has an imageView and textView (so in rtl devices the image will be at the right side of the text, see pic below)

in order to accomplish that I:

  • created v17 layout (see below).
  • added android:supportsRtl="true" in the manifest

the layout code:

<RelativeLayout
    android:id="@id/asked_by_container"
    android:layout_alignParentTop="true"
    android:layout_width="match_parent"
    android:layout_height="34dp"
    android:layout_centerHorizontal="true">

    <ImageView
        android:layout_width="34dp"
        android:layout_height="34dp"
        android:id="@+id/profile_imageview"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:background="@drawable/question_profile_icon_corner_radius"
        android:scaleType="centerCrop"
        android:src="@drawable/anonprofile01" />

    <com.theapp.widget.CustomTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/asked_textview"
        android:layout_centerVertical="true"
        android:layout_toEndOf="@+id/profile_imageview"
        android:layout_marginStart="8dp"
        android:textSize="14sp"
        app:ttf_name="fonts/merriweather_sans/MerriweatherSans-Regular.otf"/>
</RelativeLayout>

<com.theapp.widget.CustomTextView
    android:layout_below="@id/asked_by_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="New Text"
    android:id="@+id/question_textview"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:paddingStart="8dp"
    android:paddingEnd="8dp"
    android:textSize="16sp"
    android:layout_marginTop="4dp"
    app:ttf_name="fonts/merriweather_sans/MerriweatherSans-Regular.otf"/>

the preview shows that it should work: android studio regular and rtl preview

To be sure I added rootView.setLayoutDirection(View.LAYOUT_DIRECTION_RTL); in the adapter holding the RelativeLayout.

It didnt work so I made sure the app is actually using the v17 version (by adding a dummy button in the v17 version).. still not working.. any help?

I also checked Force RTL layout direction not working for app but it wasn't useful to me..

1
Hi, have you found the answer I'm confronting a similar issue.PaulNunezM
no. I just didn't have so much time to solve this, so I just done it programmatically. I used this func: public static boolean isRTL(Context ctx) { Configuration config = ctx.getResources().getConfiguration(); return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; }amdev

1 Answers

0
votes

Once set layoutDirection opposite to the textDirection

and once set layoutDirection same as the textDirection

to see which one could help you in your situation.