Animate Android Notification Icon
You can animate your Android app’s notification icon. To animate the notification icon, you have to define animation-list
in drawable directory like this. As you know, each icon image should be alpha-only.
<?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/awesome_notification_icon_1" android:duration="200" />
<item android:drawable="@drawable/awesome_notification_icon_2" android:duration="200" />
<item android:drawable="@drawable/awesome_notification_icon_3" android:duration="200" />
<item android:drawable="@drawable/awesome_notification_icon_4" android:duration="200" />
</animation-list>
Once you created an animation-list
file, you can set it as small icon of notifications. See the part of setSmallIcon(R.drawable.awesome_animation)
.
package com.example.app
import android.app.NotificationChannel
import android.app.NotificationManager
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.NotificationCompat
import androidx.core.content.getSystemService
private const val NOTIFICATION_CHANNEL_ID = "awesome channel id"
private const val NOTIFICATION_CHANNEL_NAME = "awesome channel name"
private const val NOTIFICATION_ID = 1001
class MainActivity : AppCompatActivity(R.layout.activity_main) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// get notification manager with ktx
val manager = requireNotNull(
getSystemService<NotificationManager>()
)
// create notification channel
val channel = NotificationChannel(
NOTIFICATION_CHANNEL_ID,
NOTIFICATION_CHANNEL_NAME,
NotificationManager.IMPORTANCE_DEFAULT
)
manager.createNotificationChannel(channel)
// create notification
val notification = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.drawable.awesome_animation)
.setContentTitle("awesome notification title")
.setContentText("awesome notification text")
.build()
manager.notify(NOTIFICATION_ID, notification)
}
}
This would make your notification icon animated!
About me 😎

茨城県つくば市在住のソフトウェアエンジニアです。専門領域はAndroidアプリ開発で、特にアーキテクチャに興味があります。某社でAndroidアプリ開発のテックリードをしています。
Jetpack ComposeによるAndroid MVVMアーキテクチャ入門の著者です。
👉 もっと詳しく
Writing 📝
Android MVVMアーキテクチャ入門
Androidアプリ開発の初学者に向けた、MVVM(Model-View-ViewModel)アーキテクチャの入門書を書きました。初学者の方を確実にネクストレベルに引き上げる技術書です。
👉 もっと詳しく