0

The android developer page gives the following information on the variable option for peek cards:

When this peek mode is selected, peek cards will be as tall as needed, while maintaining enough space at the top to draw the system time and status icons.

How can one tell the card how much space it has?

I ask because my cards seem to be displaying as short but the face adjusts to the size of the cards and two lined cards are desired.

EDIT: I did not get the behavior that I was looking for because I used the wrong method to change the settings. Since the integers being called had meanings for the function, the program operated.

.setCardPeekMode(WatchFaceStyle.PEEK_MODE_VARIABLE)
.setPeekOpacityMode(WatchFaceStyle.PEEK_OPACITY_MODE_TRANSLUCENT

PEEK_OPACITY_MODE_TRANSLUCENT is the same value (1) as PEEK_MODE_SHORT so the second line over rode the first.

The correct code is:

.setCardPeekMode(WatchFaceStyle.PEEK_MODE_VARIABLE)
.setPeekOpacityMode(WatchFaceStyle.PEEK_OPACITY_MODE_TRANSLUCENT)
kjl
  • 311
  • 3
  • 13

2 Answers2

0

The card may cover a significant portion of the screen, depending on the system UI style. Your watch face should adapt to these situations by ensuring that users can still tell the time while the notification card is present.

To determine the free space above the peek card so you can adapt your watch face, use the WatchFaceService.Engine.getPeekCardPosition() method.

Watch faces should not interfere with system UI elements, as described in Accommodate System UI Elements. If your watch face has a light background or shows information near the bottom of the screen, you may have to configure the size of notification cards or enable background protection.

@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());
...
}

The code snippet above configures peeking cards to be a single line tall, the background of a peeking card to show only briefly and only for interruptive notifications, and the system time not to be shown.

Update

Or you can use relative measurements, we all know that devices has different sizes and resolutions.

Must get the width and height by using Canvas.getWidth() and 'Canvas.getHeight()` methods ans set the positions of your graphic elements using values that are fraction of the detected screen size. If you resize the elements of your watch face in response to a peek card, use values that are some fraction of the remaining space above the card to redraw your watch face.

Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30
  • I have my watch configured to adjust to the size of the peek card. And I want the peek cards to be variable, and I have them set to variable. My issue is that peak cards that take two lines on some other watch faces are only using one line. So for a music player, it will only display the song title and not the artist. My question is how can I tell the peek card handler that the peek cards will get as much space as they need, and they're welcome to it. – kjl Jul 20 '16 at 02:46
0

Be sure to use .setCardPeekMode() for the height of the card and .setPeekOpacityMode() for translucency.

Because the same integer values are called for height and opacity, it is possible to use WatchFaceStyle.PEEK_OPACITY_MODE_OPAQUE in setCardPeekMood and WatchFaceStyle.PEEK_OPACITY_MODE_TRANSLUCENT in setPeekOpacityMode(). This can cause undesired effects.

kjl
  • 311
  • 3
  • 13