I am developing android application with supporting Arabic & English Language
For the Arabic language i was followed below steps :
- Android Studio > Refactor > Add RTL support where possible…
- 2nd I'll paste this line in
manifest.xml
:android:supportsRtl="true"
or
- I was changed layout property
Left
andRight
withStart
andEnd
Wow I'm happy after this changes because when i select Arabic Language some design is going to LTR
but when i test my application i found some issues.
For example see below image :
When i set RTL
You can see birthday(15/05/1994) is shown as LTR
and all text shown as RTL
(DOB,Gender,City).
Here is a problem birthday is show as 'LTR' then WHY other EditText is not going to RTL
.
Here you can see my code :
<RelativeLayout
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/_15sdp"
android:layout_marginStart="@dimen/_15sdp"
android:layout_marginTop="@dimen/_12sdp"
android:layout_width="match_parent">
<TextView
android:id="@+id/tv_age"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_5sdp"
android:layout_width="wrap_content"
android:text="@string/dob"
android:textColor="@color/color_gray"
android:textSize="@dimen/normal_input_text_size" />
<EditText
android:background="@null"
android:focusable="false"
android:gravity="end"
android:id="@+id/edit_dob"
android:layout_alignParentEnd="true"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_10sdp"
android:layout_toEndOf="@+id/tv_age"
android:layout_width="wrap_content"
android:singleLine="true"
android:text="15/05/1994"
android:textSize="@dimen/normal_input_text_size" />
</RelativeLayout><include layout="@layout/half_view" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_12sdp"
android:layout_marginStart="@dimen/_15sdp"
android:layout_marginEnd="@dimen/_15sdp"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/gender"
android:layout_centerVertical="true"
android:textSize="@dimen/normal_input_text_size"
android:textColor="@color/color_gray"
android:layout_marginStart="@dimen/_5sdp" />
<EditText
android:id="@+id/edit_gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/tv_gender"
android:layout_marginStart="@dimen/_10sdp"
android:layout_alignParentEnd="true"
android:gravity="end"
android:text="Male"
android:focusable="false"
android:textSize="@dimen/normal_input_text_size"
android:background="@null"
android:singleLine="true" />
</RelativeLayout><include layout="@layout/half_view" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_12sdp"
android:layout_marginStart="@dimen/_15sdp"
android:layout_marginEnd="@dimen/_15sdp"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/city"
android:layout_centerVertical="true"
android:textSize="@dimen/normal_input_text_size"
android:textColor="@color/color_gray"
android:layout_marginStart="@dimen/_5sdp" />
<EditText
android:id="@+id/edit_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/tv_city"
android:layout_marginStart="@dimen/_10sdp"
android:layout_alignParentEnd="true"
android:gravity="end"
android:focusable="false"
android:text="Patan"
android:textSize="@dimen/normal_input_text_size"
android:background="@null"
android:singleLine="true" />
</RelativeLayout>
Try this.
In RTL when you have set text as numeric this things happen.
LayoutDirection property added from API 19 please check Reference
Add below property to Edittext.
android:layoutDirection="ltr"
RTL ScreenShot
LTR Screenshot
For more info check this reference For RTL support