Android Studio Creating Notification Badge

In this Android Studio article, we are going to learn about Creating Notification Badge in Android Studio, Badge Notifications are  used to show the number of notifications, messages, and product count. Plenty of Android apps use badges these days. There’s no simple way to do it, so we’ll do it by coding it ourselves.  also you can check my more android development articles in the below line.

 

 

 

Also you can read more android development articles

1: Android Development Articles

 

 

 

First of all create a new project in your Android Studio, and choose Empty Activity

also iam using API 22 for this project.

 

 

 

 

After creating of the Project, you need to open build.gradle(Module:app) and add

this library, because we are using third party library, and sync your project

 

 

 

 

 

So now you need create a resource file by right clicking on drawable folder and choosing

Drawable Resource File. also you need to give a name for that, in my case i have

given badge_file.xml, it is just an xml file and you need to add these codes in that file.

 

 

 

 

 

OK after that you need to add an icon in your drawable folder, for example it should be

an email icon or a chat icon, what ever you want you can use, i have just used a notification

icon. after that we are going to design our activity_main.xml , and we are going to add this

code in their.

 

basically in the above xml code, iam using ConstraintLayout, also i have added an ImageView

with the icon that i have already added in my drawable folder. also you need to create two

buttons with the BadgeNotification library.

 

 

 

 

 

Now it is time to open your MainActivity.java, and add this code. we have just created the

object of NotificationBadge with the two Button, also we have created a variable of int

and we have initialized that to zero. also you need to set onClickListeners for the two buttons.

 

 

 

 

 

 

So now if you run the project this will be the result

Android Studio Creating Notification Badge
Android Studio Creating Notification Badge

 

 

 

 

 

Also you can watch the complete video for this article

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Comments are closed.

Share via
Copy link
Powered by Social Snap
×