网格布局方向代号one
Grid layout orientation codenameone
我在表格中设置了一个包含 3 列的网格布局。每个单元格都有一个按钮设置如下。
findLiveTraffic(f).setIcon(liveTraffic);
findLiveTraffic(f).getAllStyles().setBgColor(0x33739f);
findReports(f).setIcon(trafficReport);
findReports(f).getAllStyles().setBgColor(0x33739f);
等等。
当我纵向查看它时效果很好,然后如果我也切换到横向,布局也很合适。但是,如果我在启动时首先以横向模式查看应用程序,然后再以纵向模式查看应用程序,则按钮及其图标在纵向模式下会不按比例缩放(横向模式才可以)。
首次横向查看:
现在纵向:
但是,如果我在应用程序启动时首先以纵向方式查看它,那么它在两个视图中都可以正常工作。我该如何解决?
将 LiveTraffic
和 Reports
封装在一个容器中,设置该容器的背景颜色并将组件的背景图像设置为您的图像:
findLiveTraffic(f).getAllStyles().setBgImage(liveTraffic);
findLiveTrafficContainer(f).getAllStyles().setBgColor(0x33739f);
findReports(f).getAllStyles().setBgImage(trafficReport);
findReportsContainer(f).getAllStyles().setBgColor(0x33739f);
我在表格中设置了一个包含 3 列的网格布局。每个单元格都有一个按钮设置如下。
findLiveTraffic(f).setIcon(liveTraffic);
findLiveTraffic(f).getAllStyles().setBgColor(0x33739f);
findReports(f).setIcon(trafficReport);
findReports(f).getAllStyles().setBgColor(0x33739f);
等等。
当我纵向查看它时效果很好,然后如果我也切换到横向,布局也很合适。但是,如果我在启动时首先以横向模式查看应用程序,然后再以纵向模式查看应用程序,则按钮及其图标在纵向模式下会不按比例缩放(横向模式才可以)。
首次横向查看:
现在纵向:
但是,如果我在应用程序启动时首先以纵向方式查看它,那么它在两个视图中都可以正常工作。我该如何解决?
将 LiveTraffic
和 Reports
封装在一个容器中,设置该容器的背景颜色并将组件的背景图像设置为您的图像:
findLiveTraffic(f).getAllStyles().setBgImage(liveTraffic);
findLiveTrafficContainer(f).getAllStyles().setBgColor(0x33739f);
findReports(f).getAllStyles().setBgImage(trafficReport);
findReportsContainer(f).getAllStyles().setBgColor(0x33739f);