如何解决在Android中右对齐文字?
| 我需要做些特殊的事情来使文本在ѭ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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。