Android Viewbadger 实现消息数字提示
2015-01-12 16:56
453 查看
Code
Issues11
Pull
Requests0
Pulse
Graphs
You can clone with HTTPS orSubversion.
Clone
in Desktop Download
ZIP
A simple way to "badge" any given Android view at runtime without having to cater for it in layout
21 commits
2 branches
0 releases
1 contributor
Java 100%
Java
branch: master
android-viewbadger/
1
comment
added
note on action bar limitations
latest
commit e08c3a78cb
jgilfelt authored on
12 Jan 2013
A simple way to "badge" any given Android view at runtime without having to cater for it in layout.
Note: If your aim is to replicate the iOS icon and TabBar badge UI for notifications, consider using Android UI conventions such as the number field of the Notification class
rather than this method.
Simple example:
This project contains a fully working example application. Refer to the
for more custom badge examples, including custom backgrounds and animations.
you can use all of
To use ViewBadger in your own Android project, simply copy
from this repository's package downloads) into your project's
Badging Action Bar items is currently not supported #2
Badging views inside RelativeLayout with dependencies may break alignment #1
Author: Jeff Gilfelt
The code in this project is licensed under the Apache Software License 2.0.
Copyright (c) 2011 readyState Software Ltd.
android的viewbadger"徽章"任何给定的Android视图,而无需在运行时布局,以迎合在一个简单的方法
2、使用方法
先导入android-viewbadger.jar
然后直接在activity如下操作
View target = findViewById(控件id识别);//target为你想显示badges的控件
BadgeView badge = new BadgeView(this, target);badge.setText("1");
badge.show();//或者使用 badge .toggle();
扩展方法:setText(),
setTextColor(Color.BLUE),
setBadgeBackgroundColor(Color.YELLOW),
setTextSize(12),
toggle()等等;
3、资源下载地址:http://download.csdn.net/detail/shi508181017/5902419
其用法非常简单:
首先是添加数字:
[java] view
plaincopy
BadgeView badgeView = new BadgeView(MainActivity.this, iv1);
badgeView.setText("5");
badgeView.show();
然后是添加文字:
[java] view
plaincopy
BadgeView badgeView = new BadgeView(MainActivity.this, iv2);
badgeView.setText("新消息");
badgeView.setTextSize(8.5f);
badgeView.setTextColor(Color.DKGRAY);
badgeView.show();
最后是添加特定图标,只需对应drawable的id即可
[java] view
plaincopy
BadgeView badgeView2 = new BadgeView(MainActivity.this, iv3);
badgeView2.setBackgroundResource(R.drawable.noread);
badgeView2.show();
隐藏/去掉提醒图标或者数字(同正常View隐藏的方法);
[java] view
plaincopy
badgeView.setVisibility(View.GONE);
怎么样,只要是View对象即可添加提醒图标或者数字,是不是很方便,.赶紧用一下吧.
源码下载地址:
http://download.csdn.net/detail/t12x3456/5983875
Issues11
Pull
Requests0
Pulse
Graphs
HTTPS clone URL
You can clone with HTTPS orSubversion. Clone
in Desktop Download
ZIP
A simple way to "badge" any given Android view at runtime without having to cater for it in layout
21 commits
2 branches
0 releases
1 contributor
Java 100%
Java
branch: master
android-viewbadger/
1
comment
added
note on action bar limitations
latest
commit e08c3a78cb
jgilfelt authored on
12 Jan 2013
lib | moved packaged jar to resolve build issue with recent ADT | 2 years ago | |
res | new constructor and logic to better handle TabWidget target, addition… | 3 years ago | |
src | allow margins to be set independently, center position option, | 3 years ago | |
.classpath | moved packaged jar to resolve build issue with recent ADT | 2 years ago | |
.gitignore | first commit | 3 years ago | |
.project | first commit | 3 years ago | |
AndroidManifest.xml | README.markdown update | 3 years ago | |
LICENSE | first commit | 3 years ago | |
README.markdown | added note on action bar limitations | 2 years ago | |
proguard.cfg | first commit | 3 years ago | |
project.properties | update for tools r14 | 3 years ago |
README.markdown
Android
ViewBadger
A simple way to "badge" any given Android view at runtime without having to cater for it in layout.Note: If your aim is to replicate the iOS icon and TabBar badge UI for notifications, consider using Android UI conventions such as the number field of the Notification class
rather than this method.
Usage
Simple example:View target = findViewById(R.id.target_view); BadgeView badge = new BadgeView(this, target); badge.setText("1"); badge.show();
This project contains a fully working example application. Refer to the
DemoActivityclass
for more custom badge examples, including custom backgrounds and animations.
BadgeViewis a subclass of
TextViewso
you can use all of
TextView's methods to style the appearance of your badge.
To use ViewBadger in your own Android project, simply copy
android-viewbadger.jar(available
from this repository's package downloads) into your project's
/libsdirectory and add it to the build path.
Current
Limitations
Badging Action Bar items is currently not supported #2Badging views inside RelativeLayout with dependencies may break alignment #1
Credits
Author: Jeff GilfeltThe code in this project is licensed under the Apache Software License 2.0.
Copyright (c) 2011 readyState Software Ltd.
android的viewbadger"徽章"任何给定的Android视图,而无需在运行时布局,以迎合在一个简单的方法
2、使用方法
先导入android-viewbadger.jar
然后直接在activity如下操作
View target = findViewById(控件id识别);//target为你想显示badges的控件
BadgeView badge = new BadgeView(this, target);badge.setText("1");
badge.show();//或者使用 badge .toggle();
扩展方法:setText(),
setTextColor(Color.BLUE),
setBadgeBackgroundColor(Color.YELLOW),
setTextSize(12),
toggle()等等;
3、资源下载地址:http://download.csdn.net/detail/shi508181017/5902419
其用法非常简单:
首先是添加数字:
[java] view
plaincopy
BadgeView badgeView = new BadgeView(MainActivity.this, iv1);
badgeView.setText("5");
badgeView.show();
然后是添加文字:
[java] view
plaincopy
BadgeView badgeView = new BadgeView(MainActivity.this, iv2);
badgeView.setText("新消息");
badgeView.setTextSize(8.5f);
badgeView.setTextColor(Color.DKGRAY);
badgeView.show();
最后是添加特定图标,只需对应drawable的id即可
[java] view
plaincopy
BadgeView badgeView2 = new BadgeView(MainActivity.this, iv3);
badgeView2.setBackgroundResource(R.drawable.noread);
badgeView2.show();
隐藏/去掉提醒图标或者数字(同正常View隐藏的方法);
[java] view
plaincopy
badgeView.setVisibility(View.GONE);
怎么样,只要是View对象即可添加提醒图标或者数字,是不是很方便,.赶紧用一下吧.
源码下载地址:
http://download.csdn.net/detail/t12x3456/5983875
相关文章推荐
- Android Viewbadger 实现消息数字提示
- Android 实现带角标的ImageView(微博,QQ消息提示)
- 实现悬浮的数字:Android ViewBadger
- Android仿微信未读消息数提示数字之BadgeView的使用
- Android AutoCompleteTextView控件实现类似百度搜索提示,限制输入数字长度
- 【Android】viewbadger实现未读消息红点提醒,并显示条数
- Android ViewBadger实现悬浮的数字
- Android ViewBadger实现悬浮的数字
- Android实现微信底部的带消息提示数量
- android AutoCompleteTextView 实现输入提示,类似百度支持输入拼音提示中文(gray)
- Android实现微信底部的带消息提示数量
- Android BadgeView使用介绍 (数字提醒提示)
- Android:AutoCompleteTextView实现历史记录提示
- Android实现微信底部的带消息提示数量
- android自定义tabbar,并带badgeview消息提示
- android消息提示控件badgeview使用tips
- Android开发————Android用AutoCompleteTextView实现搜索历史记录提示
- 我的Android进阶之旅------>Android之AutoCompleteTextView输入汉字拼音首字母实现过滤提示(支持多音字)
- Android用AutoCompleteTextView实现搜索历史记录提示
- 我的Android进阶之旅------>Android用AutoCompleteTextView实现搜索历史记录提示