[英]How to aligning textviews on the left and right side of a linearlayout
根據以下代碼
<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>
TextView對齊不正確,並且兩者都不在同一行。
就像下圖所示。
請檢查父級布局,然后嘗試將方向設置為水平。 我嘗試了不同的情況,但發現它在所有情況下都有效...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.