4

While developing Android Wear watch face, how can one detect if screen is round and has chin (aka flat tire band), like Moto 360? I tried onSurfaceChanged, but width and height are identical overthere.

I tried this on emulator having chin, but still can't detect chin, is the problem with emulator or my code?:

@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;
 }
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210

2 Answers2

9

I am using:

insets.getSystemWindowInsetBottom() > 0

This is working for me on the emulator, but I don't have a real device to test it on.

Hakanai
  • 12,010
  • 10
  • 62
  • 132
2
//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"
}