0

我注意到天氣時間表(例如)在peek和環境中都顯示兩行的通知。我想複製這個我的要求,但我無法這樣做。我試過InboxStyle和BigTextStyle無濟於事。圖標位置也不同,可以顯示更多標題。Android Wear通知佈局 - 兩行在peek和環境中

這是可能的,或者是因爲天氣時間線是一個「穿戴應用程序」?

wear_notify

 NotificationCompat.Builder notificationBuilder = 
      new NotificationCompat.Builder(this) 
        .setSmallIcon(R.drawable.ic_launcher) 
        .setContentTitle("TestTitle") 
        .setContentText("TestContextTextLoremIpsum"); 

回答

0

通知卡可以覆蓋屏幕的一部分顯著,取決於system UI style。您的錶盤應適應這些情況,確保用戶在通知卡出現時仍可以告訴時間。

您需要確定peek卡上方的空閒空間,以便您可以調整您的錶盤面,使用WatchFaceService.Engine.getPeekCardPosition()方法。這提供了它的位置,當它在底部窺視並允許表面暴露時。

手錶表面不應該干擾系統UI元素,如Accommodate System UI Elements中所述。如果您的錶盤背景較淺或靠近屏幕底部顯示信息,則可能需要配置通知卡的尺寸或啓用背景保護。

@Override 
public void onCreate(SurfaceHolder holder) { 
super.onCreate(holder); 

// configure the system UI 
setWatchFaceStyle(new WatchFaceStyle.Builder(AnalogWatchFaceService.this) 
.setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT) 
.setBackgroundVisibility(WatchFaceStyle 
.BACKGROUND_VISIBILITY_INTERRUPTIVE) 
.setShowSystemUiTime(false) 
.build()); 
... 
} 

代碼段以上配置偷看卡是一個單一的線高,一個窺視卡的背景,只顯示簡要地並且僅用於斷流的通知,和系統時間不被示出。