2016-01-28 37 views
3

在開發Android Wear手錶時,如何檢測屏幕是圓的還是下巴(又稱扁平帶),如Moto 360? 我試過onSurfaceChanged,但寬度和高度相同。檢測Android Wear屏幕是否有下巴(又名癟胎)

我想這在具有下巴模擬器,但仍無法檢測的下巴,與仿真器或我的代碼?:

@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; 
} 

回答

7

問題我使用:

insets.getSystemWindowInsetBottom() > 0 

這是在模擬器上爲我工作,但我沒有一個真正的設備來測試它。