【问题标题】:How to inline wrap layouts?如何内联换行布局?
【发布时间】:2011-09-28 04:00:02
【问题描述】:

我们如何在 Android 中制作内联布局?

类似这样的:

我尝试在相对布局中使用边距,但它们被分成 2 列而不是相互包裹:

<RelativeLayout
    android:id="@+id/Container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RelativeLayout
            android:id="@+id/Layout1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="60sp">
            .... //something here
    </RelativeLayout>
    <RelativeLayout
            android:id="@+id/Layout2"
            android:layout_width="60sp"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true">
             .... //something here
    </RelativeLayout>
</RelativeLayout>

【问题讨论】:

    标签: android layout inline word-wrap


    【解决方案1】:

    Layout2 的宽度为 60dp,在 layout1 中,您将边距设置为 60dp,以便它们看起来像两列如果您想检查它,请将 layout1 的边距更改为 30dp,您将看到环绕效果 并在布局中放置一些控件,以便您可以看到该区域

    【讨论】:

    • 如果我删除边距,layer1 的内容会渲染在 layer2 上。我想这是因为 android:layout_alignParentRight="true" 不会使 layer2 成为“float-inline”而是“float-underline”。
    猜你喜欢
    • 1970-01-01
    • 2020-01-26
    • 2016-10-08
    • 1970-01-01
    • 2019-06-09
    • 1970-01-01
    • 1970-01-01
    • 2019-01-27
    • 1970-01-01
    相关资源
    最近更新 更多