我有这个 XML 代码,它生成一个按钮、一个文本视图和另一个按钮,如何让按钮出现在最左边,文本视图出现在中间,最后一个按钮出现在最右边?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel">
</Button>
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Place">
</TextView>
<Button android:id="@+id/Button03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save">
</Button>
</LinearLayout>
我建议使用RelativeLayout,它使事情变得更容易。
通过使用RelativeLayout,您可以将textview设置为在父级中水平居中或在父级中居中
完成此操作后,您可以通过将这些按钮与父边对齐来将它们直接附加到远端,或者将它们直接附加到文本视图的侧面,也许添加一点填充,然后您就得到了间距。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)