我正在开发一个小应用程序,左上角有 3 个按钮(垂直),还有一个编辑框覆盖了屏幕的其余部分。
我想运行此应用程序以便能够在所有屏幕分辨率下运行。 所以我对按钮使用了相对布局、线性布局和 Android:weight,它们均等地共享按钮的大小并且工作正常。
我的问题是我做错了吗?
我们应该为不同的屏幕设计不同的布局还是使用相同的布局但添加权重和填充等属性就可以了?
最佳答案
So, you want a responsive layout for your android app.
指向您的问题:
[+1] layout -> Relative / Linear (in addition to the relative layout)
property (Buttons) -> Android:weight
是您为应用所做的正确事情。
替代方案:
但是如果你想要更多responsive design然后您可以使用 html5 和 css3 媒体查询等来遵循响应式设计技术。并且,也可以选择流畅的布局。通过这样做,您将拥有的优势是:
Won't have a native UI only for android but the same could be used for other platforms (iOS,blackberry etc.) if you require.
The design would be more seamless with the native browser and the widgets won't get obsolete ever in the newer versions of your android platform also and changes once done would be reflected over the other platforms too.
更多信息:如果您想清楚地了解如何为 Android 设计,则必须阅读
http://developer.android.com/design/style/devices-displays.html http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm
关于java - 为不同屏幕设计 xml 布局 : Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11876705/