实际上BadgeView这个类就是继承TextView的。很多TextView中设置字体的方法都适用于BadgeView。
1. setTargetView(View) --> 设置哪个控件显示数字提醒,参数就是一个view对象
2. setBadgeCount(int) --> 设置提醒的数字
3. setBadgeGravity(Gravity) --> 设置badgeview的显示位置
4. setBackgroundColor() --> 设置badgeview的背景色,当然还可以设置背景图片
5. setBackgroundResource() --> 设置背景图片
6. setTypeface() --> 设置显示的字体
7. setShadowLayer() --> 设置字体的阴影
- badgeView = new BadgeView(this);
- badgeView.setTargetView(layout);
- badgeView.setBackground(12, Color.parseColor("#9b2eef"));
- badgeView.setText("提示");
badgeView = new BadgeView(this);
badgeView.setTargetView(layout);
badgeView.setBackground(12, Color.parseColor("#9b2eef"));
badgeView.setText("提示");
- 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.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);