BadgeView 圆形数字提醒 购物车常用

实际上BadgeView这个类就是继承TextView的。很多TextView中设置字体的方法都适用于BadgeView。

1. setTargetView(View) --> 设置哪个控件显示数字提醒,参数就是一个view对象

2. setBadgeCount(int) --> 设置提醒的数字

3. setBadgeGravity(Gravity) --> 设置badgeview的显示位置

4. setBackgroundColor() --> 设置badgeview的背景色,当然还可以设置背景图片

5. setBackgroundResource() --> 设置背景图片

6. setTypeface() --> 设置显示的字体

7. setShadowLayer() --> 设置字体的阴影

  1. badgeView = new BadgeView(this);
  2. badgeView.setTargetView(layout);
  3. badgeView.setBackground(12, Color.parseColor("#9b2eef"));
  4. badgeView.setText("提示");
badgeView = new BadgeView(this);
badgeView.setTargetView(layout);
badgeView.setBackground(12, Color.parseColor("#9b2eef"));
badgeView.setText("提示");
  1. badgeView = new BadgeView(this);
  2. badgeView.setTargetView(layout);
  3. badgeView.setBadgeGravity(Gravity.BOTTOM | Gravity.CENTER);
  4. badgeView.setBadgeCount(4);
badgeView = new BadgeView(this);
badgeView.setTargetView(layout);
badgeView.setBadgeGravity(Gravity.BOTTOM | Gravity.CENTER);
badgeView.setBadgeCount(4);
  1. badgeView = new BadgeView(this);
  2. badgeView.setTargetView(layout);
  3. badgeView.setBadgeGravity(Gravity.TOP | Gravity.LEFT);
  4. badgeView.setTypeface(Typeface.create(Typeface.SANS_SERIF,
  5. Typeface.ITALIC));
  6. badgeView.setShadowLayer(2, -1, -1, Color.GREEN);
  7. badgeView.setBadgeCount(2);
上一篇:纯css3跑马灯demo


下一篇:高通平台FastMMI(FFBM模式)简介与进入方法