这是 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Welcome"
android:layout_centerInParent="true" android:textSize="20sp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Welcome"
android:layout_centerInParent="true" android:textSize="20sp"/>
</RelativeLayout>
</RelativeLayout>
这不是真正的场景(UI 设计不是那个代码,但我将其呈现为简化)。我从这段代码中得到的除了是 TextViews 将相对地(以垂直方式)一个一个地显示。喜欢:
Welcome
Welcome
但相反,输出如下:
Welcome
就像,它们嵌套在一起,彼此堆叠。我将宽度布局设置为填充父级,那么为什么其他布局没有下降?它覆盖了第一个相对布局。
我必须有 2 个布局,所以请不要建议我只创建一个布局。
谢谢你。