我有這種線性佈局和線性佈局內我有幾個文本視圖。 現在我想要做的是在左側顯示信息文本,然後顯示它旁邊的值,但值應該在最長的信息文本後對齊。Android UI如何對齊textviews?
我看不到我可以如何使用線性佈局內的另一個線性佈局。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
android:text="Room:"
android:textSize="12dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
android:text="{value}"
android:textSize="12dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
android:text="Date:"
android:textSize="12dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
android:text="{value}"
android:textSize="12dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
android:text="Time:"
android:textSize="12dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
android:text="{value}"
android:textSize="12dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
android:text="Location"
android:textSize="12dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"
android:text="{value}"
android:textSize="12dp" />
</LinearLayout>
像一張html表格。一個與信息文本,然後是下一個值。 帶有文本值的文本視圖應該在最長的信息文本之後對齊。
的Html相當於
<table>
<tr>
<td>Room:</td>
<td>{value}</td>
</tr>
<tr>
<td>Date:</td>
<td>{value}</td>
</tr>
...
</table>
,纔有可能對準這除了投入固定DP寬度是多少?