Cross platform UI spacing/padding

旧巷老猫 提交于 2019-12-11 03:24:15

问题


I have written a Java UI using the SWT UI library and the MigLayout layout library.

This page shows screenshots of the UI on Windows, Linux and OSX: http://mchr3k.github.com/org.intrace/screenshots.html

On Linux and OSX my UI has a lot more padding and spacing which I feel wastes a lot of screen space. Is this normal for these platforms? If not, what is the best way to work around this?

EDIT: the linked screenshots have now been updated and no longer show an extra gap on OSX as I have explicitly set the margins on some of my UI elements to 0. The OSX UI is still quite spaced out but I assume that this is correct for the platform.


回答1:


This is Mikael Grev, the creator of MigLayout.

As someone else mentioned this is a feature of MigLayout. Instead of using x number of pixels (you can of course use that too) by default it is using gaps like related, unrelated and paragraph. These correspond to different sizes in different UI toolkits. For instance on OS X the recommended white space between components is larger than on Windows.

So, yes, this is how it's supposed to look and it will look correct for a native OS X user.

You do seem to have too much white space at the bottom of the Output pane though, in both OS X and Windows.

You can use the PlatformDefaults class in MigLayout to either force a platform or to change the default gaps. Check the source code if you want to know what's happening behind the scenes.

And remember, this is a feature so that every developer won't have to keep track of how to spacing should look like on different platforms, which is kind of hard.

Cheers, Mikael




回答2:


That's actually a feature of MigLayout, if I recall correctly. If you don't want this I am sure you could so configure MigLayout. Otherwise, you could use a different layout manager (but I still highly recommend a table-based one) which uses constant spacing for all platforms (such as my MatrixLayout).



来源:https://stackoverflow.com/questions/6325430/cross-platform-ui-spacing-padding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!