Application market Many applications will see some of the effects of the number of red dots, such as QQ, as well as some tips to update the app, in order to achieve better application of the hint function, this article will introduce an open source control to implement red dot update information hint effect.
First, badgeview commonly used methods introduced:
1.setBadgeCount (int): Set reminder number
2.setBadgeGravity (Gravity): Set Location layout
3.setTargetView (View): Set prompt Control object
4.setTypeface (): Set Display font
5.setShadowLayer (): Set Font Shadow
6.setBackgroundColor (): Set background color
7.setBackgroundResource (): Set background picture
Second, the construction of third-party tools source code
Compile files (' Libs/badgeview.jar ')
Second, the code to achieve four kinds of effects
1. Effect One:
Badgeview badgeView1 = new Com.jauker.widget.BadgeView (this); Badgeview1.settargetview (MTIPTEXT1); Badgeview1.setbadgecount (3);
2. Effect Two
Badgeview badgeView2 = new Badgeview (this); Badgeview2.settargetview (MTIPTEXT2); Badgeview2.setbackground (12, Color.parsecolor ("#9b2eef")); Badgeview2.settext ("hint");
3. Effect three
Badgeview badgeView3 = new Badgeview (this); Badgeview3.settargetview (MTIPTEXT3); Badgeview3.setbadgegravity ( Gravity.top | Gravity.left); Badgeview3.settypeface (Typeface.create (Typeface.sans_serif, typeface.italic)); Badgeview3.setshadowlayer (2,-1,-1, Color.green); Badgeview3.setbadgecount (2);
4. Effect Four
Mtiptext4.setonclicklistener (New View.onclicklistener () { @Override public void OnClick (view view) { TextView TextView = (TextView) Layoutinflater . from (Mainactivity.this). Inflate (r.layout.activity_main2, NULL). Findviewbyid (R.id.id_activity2_textview); Textview.settext ("the"); StartActivity (New Intent (Mainactivity.this, Mainactivity2.class));} );
Three
Four: source code download
Address: http://download.csdn.net/detail/u012721519/9743227
Good luck!
Write by Jimmy.li
Android badgeview Red dot Update info tip