user4358835
user4358835

Reputation:

How to aligning textviews on the left and right side of a linearlayout

According to below codes

<LinearLayout android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:gravity="center_vertical|center_horizontal"
                  android:layout_marginTop="15dip">
        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="نوع"
                android:gravity="left"
                android:layout_weight="1"
                android:id="@+id/txt_type" />
        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="تاریخ: ۱۳۹۲/۰۳/۲۸"
                android:layout_weight="1"
                android:gravity="right"
                android:id="@+id/txt_date" />

    </LinearLayout>

TextViews are not well aligned and both are not in exact line.

It's like what exactly showed in below picture.

enter image description here

Upvotes: 0

Views: 1113

Answers (1)

Nilay Dani
Nilay Dani

Reputation: 896

Please check the parent layout and try to set orientation to horizontal. I tried different cases but found that its working in all cases...

enter image description here

Upvotes: 1

Related Questions