我想在Notification Badge上设置动画,以及如何在imageview(Z轴)前面显示徽章
根据以下主题,我们可以看到Android不允许更改应用程序。
How to display count of notifications in app launcher icon
但是如果您仍然希望通知动画,我建议您可以为Android通知栏实施动画。
它需要一个animationfile.xml
<?xml version="1.0" encoding="utf-8" ?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/icaon" android:duration="10000" />
<item android:drawable="@drawable/ic_stat_button_click" android:duration="10000" />
</animation-list>
int icon = Resource.Drawable.animationfile;
// Build the notification:
var builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.SetAutoCancel(true) // Dismiss the notification from the notification area when the user clicks on it
.SetContentIntent(resultPendingIntent) // Start up this activity when the user clicks the intent.
.SetContentTitle("Button Clicked") // Set the title
.SetNumber(count) // Display the count in the Content Info
//.SetSmallIcon(Resource.Drawable.ic_stat_button_click) // This is the icon to display
.SetSmallIcon(icon)
.SetContentText($"The button has been clicked {count} times."); // the message to display.
// Finally, publish the notification:
var notificationManager = NotificationManagerCompat.From(this);
notificationManager.Notify(NOTIFICATION_ID, builder.Build());
这是同一个帖子,你可以看看: