检测 Android Wear screen 是否有下巴(又名漏气轮胎)
Detect if Android Wear screen has chin (aka flat tire)
在开发AndroidWear watch face的时候,怎么检测屏幕是不是圆的,有没有下巴(又名flat tire band),比如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
这在模拟器上对我有用,但我没有真正的设备来测试它。
//Kotlin
// height
val height = resources.displayMetrics.heightPixels
// width
val width = resources.displayMetrics.widthPixels
// is round?
val screenForm = resources.configuration.isScreenRound
// if true
val form = if (screenForm) {
if (height != width)
"Round chin"
else
"Round"
} else {
"Square"
}
在开发AndroidWear watch face的时候,怎么检测屏幕是不是圆的,有没有下巴(又名flat tire band),比如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
这在模拟器上对我有用,但我没有真正的设备来测试它。
//Kotlin
// height
val height = resources.displayMetrics.heightPixels
// width
val width = resources.displayMetrics.widthPixels
// is round?
val screenForm = resources.configuration.isScreenRound
// if true
val form = if (screenForm) {
if (height != width)
"Round chin"
else
"Round"
} else {
"Square"
}