首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >堆栈相对布局android

问堆栈相对布局android
EN

Stack Overflow用户
提问于 2013-09-24 04:33:02
回答 2查看 871关注 0票数 0

我应该使用哪种布局/我将如何在没有重叠的情况下将布局堆叠在一起?

我试图在一个线性布局中包含两个相对布局。相对布局需要相互垂直堆叠。我尝试了以下代码,但没有任何运气。有什么建议吗?

代码语言:javascript
复制
<LinearLayout
    android:id="@+id/headerquickmatch"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RelativeLayout
        android:id="@+id/matchnameheader"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            .../>

        <EditText
            ... />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/matchnameheader" >

        <TextView
            ... />

        <EditText
            ... />

        <Button
            ... />

    </RelativeLayout>
</LinearLayout>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-09-24 04:38:43

将android:orientation="vertical"放在父线性布局上。因此,所有的子布局(相对布局)将自动垂直堆叠。对每个布局组件使用不同的id。

票数 0
EN

Stack Overflow用户

发布于 2013-09-24 04:48:35

代码语言:javascript
复制
<LinearLayout
    android:id="@+id/headerquickmatch"
    android:layout_width="fill_parent"
    *android:orientation="vertical"*
    android:layout_height="fill_parent">

    <RelativeLayout
        android:id="@+id/matchnameheader"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            .../>

        <EditText
            ... />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/matchnameheader" >

        <TextView
            ... />

        <EditText
            ... />

        <Button
            ... />

    </RelativeLayout>
</LinearLayout>

请将orientation=vertical添加到顶部父线性layout.so中,所有子布局都将显示在堆叠布局中。

我希望这对你有用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18973014

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档