First sorry about my weak English language!
I designed a layout. This is part of the layout:
<ScrollView android:id="@+id/scrollView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dip" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/shape_details" android:orientation="vertical" android:padding="10dip" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="right" > <TextView android:id="@+id/txt_details_ostan" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="Medium Text" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#0000FF" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="استان" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#AA0000" /> </LinearLayout>
Preferred language direction is right to left. The red colors are topic, and the blue ones are text that will read from database.
The problem is that the text has many characters and when shown in this layout, the topic will be disappeared because of my layout is "left to right" and the text fill all layout.
I searched a lot but I can't find any way to change the layout "right to left".
linear layout with layout_width="fill_parent" and also the widget with same layout width + gravity as right would align it to the right.
To create a linear layout in which each child uses the same amount of space on the screen, set the android:layout_height of each view to "0dp" (for a vertical layout) or the android:layout_width of each view to "0dp" (for a horizontal layout). Then set the android:layout_weight of each view to "1" .
Android LinearLayout is a view group that aligns all children in either vertically or horizontally.
Add the following line to your layout:
android:layoutDirection="rtl" android:layout_alignParentRight="true"
Try doing this:
Here's an example:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="fill_parent" android:padding="5dip" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="10dip" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="right" > <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="استان" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#AA0000" /> <TextView android:id="@+id/txt_details_ostan" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:layout_toLeftOf="@+id/textView3" android:text="This is a sample of a long message. It will not push the topic off screen." android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#0000FF" /> </RelativeLayout> </LinearLayout> </ScrollView>
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