ro.sf.lcd_density=160
这个方法可能是系统自适应的结果,当屏幕分辨率调小后,图标都变小,此时横屏将Hotseat放在底部比较合适,相反,如果在屏幕分辨率比较大,hotseat在底部,在一定程度上回让屏幕变窄很不协调,比如之前我们的屏幕是 6*5的,如果放在底部,就变成了6*4,可以想象给人感觉都不好。
刚才是闲扯了,现在看看代码是怎么处理的。先看hotseat.xml文件这个应该是布局
该布局的逻辑主要在Hotseat.java中,我们继续进去看看
public Hotseat(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mLauncher = (Launcher) context;
mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
}
/**
* When {@code true}, hotseat is on the bottom row when in landscape mode.
* If {@code false}, hotseat is on the right column when in landscape mode.
*/
boolean isVerticalBarLayout() {
return isLandscape && transposeLayoutWithOrientation;
}
看上面的注释,大概就知道,当返回值为true时 hotseat is on the bottom row,当为false时 hotseat is on the right column;这个很接近答案了。
接着看该类的代码:
transposeLayoutWithOrientation =
res.getBoolean(R.bool.hotseat_transpose_layout_with_orientation);
public DeviceProfile(Context context, InvariantDeviceProfile inv,
Point minSize, Point maxSize,
int width, int height, boolean isLandscape) {
this.inv = inv;
this.isLandscape = isLandscape;
...
...
}
landscapeProfile = new DeviceProfile(context, this, smallestSize, largestSize,
largeSide, smallSide, true /* isLandscape */);
portraitProfile = new DeviceProfile(context, this, smallestSize, largestSize,
smallSide, largeSide, false /* isLandscape */);