首页 > 代码库 > Android Viewbadger 实现消息数字提示

Android Viewbadger 实现消息数字提示

开源组件viewbadger实现消息数字提示,项目地址:https://github.com/jgilfelt/android-viewbadger  (可获得源码)!

Author: Jeff Gilfelt

The code in this project is licensed under the Apache Software License 2.0. 
Copyright (c) 2011 readyState Software Ltd.

技术分享

 

当然,这里直接是一个jar包,导入就可使用:android-viewbadger.jar(Demo中有jar包)

技术分享

实例Demo:

MainActivity.java:

package sn.qdj.viewbadgerdemo;import com.readystatesoftware.viewbadger.BadgeView;import android.app.Activity;import android.os.Bundle;import android.view.View;public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);                View btn = findViewById(R.id.button1);        BadgeView badge = new BadgeView(this, btn);        badge.setTextSize(12);        /**         * 右上角(默认值)         */        badge.setBadgePosition(BadgeView.POSITION_TOP_RIGHT);         badge.setText("10");        badge.show();    }}

显示效果:

技术分享

Demo源码下载,请点击这里!

Android Viewbadger 实现消息数字提示