这是一道android开发题。
如果我首先使用 setContentView(R.layout.main);
将内容 View 设置为我的 xml 布局,然后使用 addContentView(layout, params)
添加另一个内容 View ,内容 View 相互重叠。我希望第二个内容 View 将自己直接定位在第一个内容 View 之下。是否有可能或者我是否需要以某种方式组合 xml 和以编程方式创建的布局?两种布局都是线性的。
提前致谢
最佳答案
将两个布局放在垂直方向的 LinearLayout
中。就是这样。
编辑:
我的意思是您必须创建一个 3 布局 xml 文件。
- 主.xml
- layout1.xml --> 你的第一个布局
- layout2.xml --> 你的第二个布局
你的主布局文件应该是这样的:
<LinearLayout android:orientation="vertical">
<include android:id="+id/lay1" android:layout="@layout/layout1"/>
<include android:id="+id/lay2" android:layout="@layout/layout2"/>
</LinearLayout>
现在你的主要布局到你的 setContentView(R.layout.main)
关于android - 布局相互叠加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3758932/