简体   繁体   中英

android rtl issue using v17 version layout

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..

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM