Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
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:
[Java]View Plaincopy print?
- Badgeview Badgeview = new Badgeview (mainactivity. this, IV1);
- Badgeview.settext ("5");
- Badgeview.show ();
Then add the text:
[Java]View Plaincopy print?
- 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
[Java]View Plaincopy print?
- 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);
[Java]View Plaincopy print?
- 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
If reproduced, please declare the source: The Sands of Time: http://blog.csdn.net/t12x3456
Add a reminder above the Android icon (ii) using the Open Source UI class library Viewbadger