如果我可以将任何东西放置在我想要的地方,如何创建布局?
我正在设计一个应用程序,屏幕上散布着许多图像、按钮和文本视图。目前我正在使用相对布局,因为它似乎是最灵活的。然而,如果我放置我的元素,它们的大小仍然仅限于与其他元素对齐。更糟糕的是,如果元素更改大小,则与其对齐的任何元素也会更改大小。
必须有一个简单的解决方案! Apple 的 nib 文件可以轻松地执行此操作,只需轻松拖放到任何位置即可;然而 android 似乎陷入了限制性的表格/线性/相对/网格布局。
如果可能的话可以通过eclipse来解决。如果没有,请指导我查看相关文档,学习通过 xml 创建自己的布局、创建巨大的网格布局或任何等待我的恐怖:) 谢谢
I'm designing an app with many images, buttons and textViews strewn across the screen. At the moment I am using the relative layout as it seemed the most flexible of the lot. However were I place my elements and their size is still restricted to being aligned with other elements. Even worse if an element changes size any elements aligned to it will also change size.
There must be a simple solution to this! Apple's nib files perform this so easily with an effortless drag and drop to any location; yet android appears to be stuck with restrictive table/linear/relative/grid layouts.
If possible can the solution be performed via eclipse. If not please guide me to the relevant documentation to learn to create my own layouts via xml, create a huge grid layout or whatever horrors await me :)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为你想要的是类似绝对布局的东西,尽管这些布局不久前已被弃用,我很确定你仍然可以通过相对布局来做到这一点,你不一定需要将过孔与另一个视图对齐,我想你可以只需做这样的事情:
我在这里所做的就是将其与父级的一侧对齐并在其之间留有边距
I think what you want is something like an absolute layout tho these were deprecated a while ago, Im pretty sure you can still do this via a Relative layout, you don't necessarily need to align the via with another view, I guess you could just do something like this:
all I'm doing here is aligning it with the side of the parent and having a margin between it
您可以使用框架布局来完成您所要求的操作并设置每个对象的位置。但这样做需要您自担风险。 Apple nib 文件允许您任意放置对象的原因是它们所有设备的长宽比都是相同的。所以你的布局只是均匀地放大和缩小。
Android 是一个更加多样化的生态系统,您应该尝试采用适应不同屏幕尺寸和方向的布局。
You can do what you ask with a Frame Layout and setting the position of each object. But do so at your own risk. The reason Apple nib files let you arbitrarily place objects is taht the aspect ratio of all their devices is the same. So your layouts just scale up and down evenly.
Android is a more diverse ecosystem, and you should try to embrace layouts that adapt to different screen sizes and orientations.
查看 Android 自定义布局 和 Android - 如何在特定点绘制字母?
您是否打算仅在特定点上使用该应用程序单一 Android 设备型号?如果是,请检查 AbsoluteLayout 的替代方案。 (FrameLayout 或relativelayout)
将“任何你想要的地方”放在任何地方并不是一个好主意,因为Android 设备有很多不同的屏幕尺寸和属性。唯一的选择是定义您自己的自定义布局。
事实上,我真的很喜欢 Android 尝试使用对齐和结构化布局视图使布局与尽可能多的设备兼容的方式。
对于 Apple 来说,这很简单,因为您只针对 iPhone,而 iPhone 在所有设备上都有固定的屏幕属性。
希望有帮助。祝你好运。
Take a look at Android custom layout and Android - How to draw a letter at a specific point?
Are you planning to only use the app on a single android device model? If yes, check AbsoluteLayout's Alternatives. (FrameLayout or RelativeLayout)
It's not a good idea to put "Anything Anywhere you want" since Android devices have a lot of different screen sizes and properties. The only option would be to define your own custom layout.
I actually really like the way Android tries to make your layout compatible with as much devices as it can using alignment and structured layout views.
The reason it's simple for Apple is that you're only targeting iPhone, which has a fixed screen properties accross all devices.
Hope it helps. Good luck.