我想在通知徽章上设置动画,以及如何在imageview(Z轴)的前面显示徽章
答案 0 :(得分:0)
根据以下线程,我们可以看到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());
这里是同一线程,您可以看一下: