GitHub control-BadgeView (Digital Reminder), githubbadgeview

Source: Internet
Author: User

GitHub control-BadgeView (Digital Reminder), githubbadgeview

The number reminds everyone to have seen it. QQ, and so on, if there is a message or reminder in the app, the user will be given a red dot or a digital dot. Some time ago, I switched my avatar to an avatar with a digital reminder, which made those with obsessive-compulsive disorder crazy.


Next, let's take a look at how to implement this effect in our app.

Developers can certainly achieve this by themselves using relative layout. It's okay, but it's too much! It will be complicated. GitHub has an open-source third-party control called BadgeView. You can use it to achieve the desired effect.

How to use it first, a simple three-line code can implement a digital reminder:

BadgeView badgeView = new com.jauker.widget.BadgeView(this);badgeView.setTargetView(textView);badgeView.setBadgeCount(3);

Take a look at the common methods in badgeview:

1. setTargetView (View) --> sets the control to display a digital reminder. The parameter is a view object.

2. setBadgeCount (int) --> set the number of the reminder

3. setBadgeGravity (Gravity) --> set the position of the badgeview

4. setBackgroundColor () --> set the background color of badgeview. You can also set the background image.

5. setBackgroundResource () --> set the background image

6. setTypeface () --> set the font to display

7. setShadowLayer () --> set the font shadow.

BadgeView = new BadgeView (this); badgeView. setTargetView (layout); badgeView. setBackground (12, Color. parseColor ("# 9b2eef"); badgeView. setText ("prompt ");

badgeView = new BadgeView(this);badgeView.setTargetView(layout);badgeView.setBadgeGravity(Gravity.BOTTOM | Gravity.CENTER);badgeView.setBadgeCount(4);

badgeView = new BadgeView(this);badgeView.setTargetView(layout);badgeView.setBadgeGravity(Gravity.TOP | Gravity.LEFT);badgeView.setTypeface(Typeface.create(Typeface.SANS_SERIF,Typeface.ITALIC));badgeView.setShadowLayer(2, -1, -1, Color.GREEN);badgeView.setBadgeCount(2);

In fact, the BadgeView class inherits TextView. Many methods for setting fonts in TextView apply to BadgeView.


OK. The effect is completed.


BadgeView download link

Download badgeview. jar

Download DEMO



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.