Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何内联换行布局?_Android_Layout_Inline_Word Wrap - Fatal编程技术网

Android 如何内联换行布局?

Android 如何内联换行布局?,android,layout,inline,word-wrap,Android,Layout,Inline,Word Wrap,我们如何在Android中制作内联布局 大概是这样的: 我尝试在相对布局中使用右边距,但它们被分成两列,而不是相互环绕: <RelativeLayout android:id="@+id/Container" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:id="@+id/La

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

大概是这样的:

我尝试在相对布局中使用右边距,但它们被分成两列,而不是相互环绕:

<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>

.... //这里有东西
.... //这里有东西

布局2的宽度为60dp,在布局1中,您将边距设置为60dp,这样它们看起来就像一个两列。如果您要检查它,请将布局1的边距更改为30dp,您将看到环绕效果
还可以在布局中放置一些控件,以便您可以看到该区域

如果我删除边距,则第1层内容将在第2层上呈现。我想这是因为android:layout\u alignParentRight=“true”不会使layer2成为“float inline”,而是“float underline”。