how to design right to left linear layout

前端 未结 2 978
遥遥无期
遥遥无期 2021-02-05 04:27

First sorry about my weak English language!

I designed a layout. This is part of the layout:

 

        
相关标签:
2条回答
  • 2021-02-05 05:11

    Try doing this:

    1. Change your LinearLayout to a RelativeLayout
    2. Align the topic to parent right
    3. Put subject text to left of the topic

    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>
    
    0 讨论(0)
  • 2021-02-05 05:27

    Add the following line to your layout:

    android:layoutDirection="rtl"
    android:layout_alignParentRight="true"
    
    0 讨论(0)
提交回复
热议问题