Mainactivity is as follows:
Package CC. testtipmessage2; import COM. readystatesoftware. viewbadger. badgeview; import android. OS. bundle; import android. widget. imageview; import android. app. activity; import android. graphics. color;/*** demo Description: * iPhone-like notification badge implementation, prompting users to have several new information ** reference materials: * https://github.com/jgilfelt/android-viewbadger * http://blog.csdn.net/t12x3456/article/details/9337555 * Thank you very much */public class mainactivity extends activity {private imageview mimageview; @ overrideprotected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); Init ();} private void Init () {mimageview = (imageview) findviewbyid (R. id. imageview); badgeview = new badgeview (mainactivity. this, mimageview); badgeview. settext ("5"); badgeview. settextsize (8.5f); badgeview. settextcolor (color. dkgray); badgeview. show ();}}
Main. XML is as follows:
<Relativelayout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: Tools = "http://schemas.android.com/tools" Android: layout_width = "match_parent" Android: layout_height = "match_parent"> <imageview Android: id = "@ + ID/imageview" Android: layout_width = "100dip" Android: layout_height = "100dip" Android: Background = "@ drawable/ic_launcher" Android: layout_centerinparent = "true"/> </relativelayout>