for example, the number of text messages or news messages is often on the image. The implementation method is as follows. You can adjust the number based on different image sizes.
Private bitmap generatenumbericon (INT resid, int newscount) {bitmap icon = bitmapfactory. decoderesource (getresources (), resid); int iconsize = icon. getwidth (); bitmap mbitmap = bitmap. createbitmap (iconsize, iconsize, config. argb_8888); canvas = new canvas (mbitmap); paint = new paint (); paint. setdither (true); paint. setfilterbitmap (true); rect src = new rect (0, 0, iconsize, iconsize); rect DST = new rect (0, 0, iconsize, iconsize); canvas. drawbitmap (icon, SRC, DST, paint); paint countpaint = new paint (paint. anti_alias_flag | paint. dev_kern_text_flag); countpaint. setcolor (getresources (). getcolor (R. color. red); countpaint. setstyle (paint. style. stroke); countpaint. settypeface (typeface. default_bold); countpaint. settextsize (iconsize * 2/3f); canvas. drawtext (string. valueof (newscount), iconsize/4, iconsize * 5/6, countpaint); Return mbitmap ;}
Reference results: