简体   繁体   English

自动组织相对布局中的视图| Android Studio

[英]Automatically organize views in relative layout | Android Studio

I need to auto-organize views in the layout. 我需要自动组织布局中的视图。 It must be by code, because I have a button to add more views. 必须使用代码,因为我有一个添加更多视图的按钮。

I need that the views put at the rigth of other view if the window have place. 如果窗口有放置位置,我需要将视图置于其他视图的严格位置。 Else, it must put bellow the first view. 否则,它必须摆在第一位。

I use a relative layout, but if there are a better way... 我使用相对布局,但是如果有更好的方法...

A exaple like i want to organize 像我这样的组织者

I recommend using the Flexbox Layout library from Google. 我建议使用Google的Flexbox布局库 It is tailor-made to lay views out in a line, but wrap to the next line if there isn't room for the next view. 它是量身定制的,可将视图排成一行,但如果没有足够的空间容纳下一个视图,则换行到下一行。

Once you've added this library to your app, you'd use a FlexboxLayout instead of a RelativeLayout as your root view. 将此库添加到应用程序后,您将使用FlexboxLayout而不是RelativeLayout作为根视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM