问题描述
|
我需要做些特殊的事情来使文本在ѭ0中正确对齐吗?
下面的简单示例似乎将文本右对齐在屏幕中心,几乎就像
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>