RTL not working for a Layout

The name of the picture


RTL not working for a Layout



I add all the necessary things to support RTL for an english arabic application



android:supportsRtl="true"



to the element in manifest file.
Change all of "left/right" layout properties to new "start/end" equivalents.
everything works fine except this layout still blank in RTL but it LTR it works like a charm:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:background="@color/white"
android:layoutDirection="rtl"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/limit_levels"
android:layout_width="match_parent"
android:gravity="center"
android:layout_weight="1"
android:layout_margin="5dp"
android:layout_height="wrap_content" >

<RelativeLayout
android:id="@+id/level1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:tint="@color/white" >
<TextView
android:id="@+id/level1_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="@drawable/rounded_corner"
android:backgroundTint="@color/soft_grey"
android:clickable="true"
android:alpha="0.3"
android:gravity="center"
android:layout_marginTop="8dp"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:text="1"
android:textColor="@color/white"
android:textSize="16sp"
android:textStyle="bold"
android:visibility="visible" />
<RelativeLayout
android:id="@+id/state_item_level1_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginLeft="15dp"
android:tint="@color/white" >
<ImageView
android:id="@+id/small_circle_level1_indicator"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginTop="3dp"
android:src="@drawable/oval_small_mail" />

<TextView
android:id="@+id/small_circle_icon_level1_indicator"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_centerInParent="true"
android:textStyle="bold"
android:layout_centerVertical="true"
android:gravity="center"
android:text="1"
android:textColor="@color/white"
android:tint="@color/white"
android:visibility="visible" />
</RelativeLayout>
<TextView
android:id="@+id/small_circle_level1"
android:layout_width="18dp"
android:layout_height="18dp"
android:background="@drawable/rounded_corner"
android:textSize="11dp"
android:textStyle="bold"
android:visibility="gone"
android:gravity="center"
android:text="+2"
android:textColor="@color/TealDark"
android:layout_alignRight="@id/small_circle_level1"
android:layout_marginBottom="25dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/state_item_infraction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="3dp"
android:tint="@color/white"
android:visibility="visible">
<TextView
android:id="@+id/infraction_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="8dp"
android:alpha="0.3"
android:background="@drawable/rounded_corner"
android:backgroundTint="@color/soft_grey"
android:clickable="true"
android:gravity="center"
android:text="Inf"
android:textColor="@color/white"
android:textSize="16sp"
android:textStyle="bold"
android:visibility="visible" />
<RelativeLayout
android:id="@+id/state_item_inf_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_marginLeft="18dp"
android:tint="@color/white" >
<ImageView
android:id="@+id/small_circle_inf_indicator"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@drawable/oval_small_mail" />

<TextView
android:id="@+id/small_circle_icon_inf_indicator"
android:layout_width="15dp"
android:layout_height="14dp"
android:layout_centerInParent="true"
android:textStyle="bold"
android:layout_centerVertical="true"
android:gravity="center"
android:text="12"
android:textSize="10sp"
android:textColor="@color/white"
android:tint="@color/white"
android:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>






1 Answer
1


//rtl
public static void forceRTLIfSupported(Window window, Activity activity) {
if (activity.getResources().getString(R.string.isRTL).equals("true")) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
window.getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
}
}
}

call all activity this method

Method.forceRTLIfSupported(getWindow(), AboutUs.this);

Method my class name





thank's but I need a solution in xml not programmatically !!
– Stanly El
6 hours ago





OK i will try find solution's
– Kishan Viramgama
6 hours ago





The only thing i see is that you're specifying everything centered and expanded. Can you provide a screenshot to see how it actually looks like?
– Daniel Andujar
5 hours ago







ok my app screen short
– Kishan Viramgama
5 hours ago





prnt.sc/kabw9x like this
– Kishan Viramgama
5 hours ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

How to scale/resize CVPixelBufferRef in objective C, iOS