i have a linear layout , which contains a textView and EditText arranged horizontally.i have an option for selecting language in prvious activity (english and arabic). when i select english the current alignment is fine but when i select Arabic it should show right to left that means the textView position should go to right (in layout it will start from left) after that the editText.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/darkblue_bg"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/editusername"
android:layout_width="196dp"
android:layout_height="wrap_content"
android:background="@drawable/textfield_default"
android:ems="10" >
</EditText>
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
anybody pls give me solution...
If you want to use both of arabic and English for example in a textview, first you should put it's layout:gravity = "start" This help you if you have an English sentence it starts by left hand side and arabic started sentence with right hand side. If you want it'a combination, you must use like this Arabic string + \u200e\u202a English string + \u202c + arabic string
And in reverse:
myEnglish String + "\u202B" + myArabicString + "\u202C" + moreEnglish
You can specify a layout that is specific to a language, by placing that layout inside an appropriate layout folder. I don't know what the code is for Arabic, but it should be something like /layout-aa/
Far better today, however, is to use a relative layout, where you use the android:gravity="start"
or similar, aligning it based on the language orientation and not strictly left/right. This is available with API version 14 and above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With