为了让 <TableLayout>
中的文本右对齐,我需要做什么特别的事情吗? ?
下面的简单示例似乎将文本右对齐到屏幕中央,就好像 layout_span
一样。没有影响。
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
>
<TableRow>
<TextView
android:text="Some text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_span="2"
/>
</TableRow>
<TableRow>
<Button
android:text="Button 1"
android:layout_weight="50"/>
<Button
android:text="Button 2"
android:layout_weight="50"/>
</TableRow>
</TableLayout>
最佳答案
已修复。
从 TextView 中删除部分:
android:layout_gravity="right"
android:layout_span="2"
TextView 中的更新部分:
android:gravity="right"
android:layout_weight="1.0"
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent" >
<TableRow>
<TextView
android:text="Some text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1.0" />
</TableRow>
<TableRow>
<Button
android:text="Button 1"
android:layout_weight="50"/>
<Button
android:text="Button 2"
android:layout_weight="50"/>
</TableRow>
</TableLayout>
关于java - 在android中右对齐文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5711046/