在开发 Android Wear 表盘时,如何检测屏幕是否是圆形且有下巴(又名扁平轮胎带),如 Moto 360?
我尝试了 onSurfaceChanged
,但宽度和高度是相同的。
我在有下巴的模拟器上尝试了这个,但仍然无法检测到下巴,是模拟器有问题还是我的代码有问题?:
@Override
void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
// check if MOTO360 or other Chin layouts
Log.d(TAG,String.format("isRound : %s, BottomInset :%d",insets.isRound()?"YES":"NO",insets.getStableInsetBottom()));
// LOG OUTPUT : isRound : YES, BottomInset :0
if (insets.isRound() && insets.getStableInsetBottom() > 0)
ClockPaintingRoutines.flat_display_mode=true;
}
最佳答案
我正在使用:
insets.getSystemWindowInsetBottom() > 0
这在模拟器上对我有用,但我没有真正的设备来测试它。
关于wear-os - 检测 Android Wear 屏幕是否有下巴(又名爆胎),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35053741/