第一步重点是找准模型,而后还是更多细节上面的工作,首先,对于真正的桌面,我们需要提供两套显示方案,分别是横屏方案和竖屏方案。两套方案的重点区别是长宽的区别。
竖屏是上下距离大,而左右距离小。 而横屏则是左右距离大,上下距离小。
于是通过将距离大的放在作为宽度还是作为长度就可以设定好布局。
其代码如下:
int smallSide = Math.min(realSize.x, realSize.y);
int largeSide = Math.max(realSize.x, realSize.y);
landscapeProfile = new DeviceProfile(context, this, smallestSize, largestSize,
largeSide, smallSide, true /* isLandscape */);
portraitProfile = new DeviceProfile(context, this, smallestSize, largestSize,
smallSide, largeSide, false /* isLandscape */);
这里要创建DeviceProfile对象。 创建DeviceProfile对象,也就是实际的硬件模型了,初始模型是部分横竖屏的,而通过创建DeviceProfile可以得出更加详细的一些内容。