如何内联换行布局?
我们如何在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>
How do we make inline layouts in Android?
Something like this:
I tried using margin right in Relative layouts but they are separated into 2 columns instead of wrapping each other:
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
布局2的宽度为60dp,在布局1中,您将边距设置为60dp,以便它们看起来像两列如果您想检查它,请将布局1的边距更改为30dp,您将看到环绕效果
并在布局中放置一些控件,以便您可以看到该区域
Layout2 have width 60dp and in layout1 you are putting margin to 60dp so that they looks like a two column If you want to check it change margin of layout1 to 30dp you will see that wrapping effect
and also put some controls inside layouts so that you can see the area