The previous article described using canvas to draw the corresponding final bitmap. In practice, in addition to adding numbers to the icons, it is possible to add icons such as red squares as reminders of new features.
So is there any way to easily add a reminder icon or number to the icons?
Yes, or with the help of the Open source project Viewbadger, this is the address on GitHub:
Https://github.com/jgilfelt/android-viewbadger
Let's look at the following:
The usage is simple:
The first is to add numbers:
- Badgeview Badgeview = New Badgeview (mainactivity. This , IV1);
- Badgeview.settext ("5");
- Badgeview.show ();
Then add the text:
- Badgeview Badgeview = New Badgeview (mainactivity. This , IV2);
- Badgeview.settext ("New Message");
- Badgeview.settextsize (8. 5f);
- Badgeview.settextcolor (Color.dkgray);
- Badgeview.show ();
Finally, add a specific icon, just the ID of the drawable
- Badgeview badgeView2 = New Badgeview (mainactivity. This , Iv3);
- Badgeview2.setbackgroundresource (R.drawable.noread);
- Badgeview2.show ();
Hide/Remove reminder icons or numbers (with normal view hidden methods);
- Badgeview.setvisibility (View.gone);
How about, as long as the View object can add a reminder icon or number, is not very convenient,. Just use it for a second.
Source:
http://download.csdn.net/detail/t12x3456/5983875