Custom notification views
Sometimes notifications created by the builder just don't provide enough flexibility compared to what is required. Sometimes notifications created by the builder just don't provide enough flexibility or customization. As a result, an entirely custom notification layout is needed to provide this level of customization.
Getting ready
If we are going to support Android versions prior to 3.0, we will have to install the Xamarin Support Library v4 NuGet or component into our project.
How to do it...
We can use RemoteViews
with a layout file to provide a custom layout for a notification:
We can also display an entirely custom view in a notification. To do this, we create a
RemoteViews
object, passing the resource ID of the layout:var view = new RemoteViews( PackageName, Resource.Layout.NotificationLayout);
We can then update the various sub views using the various setter methods, such as
SetTextViewText()
,SetProgressBar()
, andSetImageViewResource()
:view.SetTextViewText...