0

I am trying to get a notification to have the margin like this notification below:

enter image description here

You see how the white of the notification doesn't touch the edge of the screen... that's what I mean.

I tried this:

BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
bigStyle.bigText(eventDescription);

NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.ic_event)
        .setLargeIcon(BitmapFactory.decodeResource(
                getResources(), R.drawable.notif_background))
        .setContentTitle(eventTitle)
        .setContentText(eventLocation)
        .setContentIntent(viewPendingIntent)
        .addAction(R.drawable.ic_map,
                getString(R.string.map), mapPendingIntent)
        .setStyle(bigStyle);

But that produces the card touching the edge of the screen. How can I achieve this?

J_Strauton
  • 2,270
  • 3
  • 28
  • 70

3 Answers3

0

On Android Wear, the position and size of the notifications is controlled by the system. The screenshot you've posted is from an older version of Android Wear - the new styling always has cards touching the edge of the screen.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • Thanks for your response that is what I was fearing. Would you happen to have a reference to this information? I would deeply appreciate it. – J_Strauton Nov 12 '16 at 04:56
  • I don't think it is specifically called out except for the [note on the top of the training page](https://developer.android.com/training/wearables/notifications/creating.html) about only taking the text and icons from your notification. – ianhanniballake Nov 12 '16 at 05:23
0

You can create an custom view by using a RemoteView.

// Inflate the notification layout as RemoteViews

RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification);
QuokMoon
  • 4,387
  • 4
  • 26
  • 50
0

If you are still using the old version of android wear try using InboxStyle, it is the other style beside BigTextStyle.

To add the extended content to your notification, call setStyle() on the NotificationCompat.Builder object, passing it an instance of either BigTextStyle or InboxStyle.

InboxStyle inboxStyle = new NotificationCompat.InboxStyle();

Hope this helps.

Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91