Raducu Mihai
Raducu Mihai

Reputation: 343

Create a notification with different UI elements for a Music Player in Xamarin.Android

I'm trying to create a simple music player in Xamarin.Android. In my app I'm creating a started service for background streaming, and I want to create a notification for the user to be abel to interact with the service. Something like this: enter image description here

I read about notification in Xamarin.Android here, but they say nothing about adding buttons and other ui elements. So my question is how do I design a notification?

Upvotes: 0

Views: 1116

Answers (1)

Marek Rzeźniczek
Marek Rzeźniczek

Reputation: 484

Look Android documentation about custom notification layouts: https://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomNotification

  1. Create an XML layout for the notification in a separate file. You can use any file name you wish, but you must use the extension .xml

  2. In your app, use RemoteViews methods to define your notification's icons and text. Put this RemoteViews object into your NotificationCompat.Builder by calling setContent(). Avoid setting a background Drawable on your RemoteViews object, because your text color may become unreadable.

Upvotes: 1

Related Questions