Android BGABadgeView:新消息/未接来电/未读消息/新通知圆球红点提示(1)

现在很多的APP会有新消息/未接来电/未读消息/新通知圆球红点提示,典型的以微信、QQ新消息提示为例,当微信朋友圈有新的朋友更新/发布朋友圈消息后,在微信的底部切换卡上会有一个红色的小圆球红点,表示有新消息,提示用户查看。

这种红色小圆点小圆球的实现方式很多种,简单期间,一个简单思路:可以用一个Framelayout里面套一个TextView(如果有未读消息数目)或者一个圆形shape显示,以红色为背景。详细请见附录文章1、2。

另外的就是使用一些第三方的开源项目,则更为通用。比如Android BGABadgeView,Android BGABadgeView在github上的项目主页是:https://github.com/bingoogolapple/BGABadgeView-Android


BGABadgeView实现了更多类型、更复杂的这类设计开发的需求。如图所示:

但是Android BGABadgeView在其项目主页上给出的项目代码下载后导入我的Android studio出现很多配置问题,我重新把最重要的库调整好,push到一个新的地址:https://github.com/zhangphil/BGABadgeView


使用时候,直接将其下载,作为一个库导入到自己的项目中即可。

基于我整理后的这个库,我写一个简单例子。

先写布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="zhangphil.demo.MainActivity"> <cn.bingoogolapple.badgeview.BGABadgeTextView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_centerInParent="true"
android:background="@android:color/holo_blue_light"
android:text="zhang phil @ csdn"
android:textColor="@android:color/white"
app:badge_gravity="rightTop"
app:badge_dragable="true"
app:badge_padding="6dp" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示/隐藏小红点"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>

Java代码:

package zhangphil.demo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View; import cn.bingoogolapple.badgeview.BGABadgeTextView; public class MainActivity extends AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); final BGABadgeTextView badgeTextView= (BGABadgeTextView) findViewById(R.id.text);
badgeTextView.showCirclePointBadge(); findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(badgeTextView.isShowBadge())
badgeTextView.hiddenBadge();
else
badgeTextView.showCirclePointBadge();
}
});
}
}

代码运行结果:

附录文章:

1,《仿微信、短信、QQ等消息数目右上角红色小圆球气泡显示(基于Android XML布局文件实现)》链接地址:http://blog.csdn.net/zhangphil/article/details/43702953


2,《仿短信条目右上角的红色小圆球提示气泡》链接地址:http://blog.csdn.net/zhangphil/article/details/43667727

Android BGABadgeView:新消息/未接来电/未读消息/新通知圆球红点提示(1)的更多相关文章

  1. Android BGABadgeView:BGABadgeFrameLayout(5)

     Android BGABadgeView:BGABadgeFrameLayout(5) BGABadgeView除了有自己的线性布局,相对布局外(见附录文章7,8),还实现了FrameLayou ...

  2. Android BGABadgeView:BGABadgeImageView以及BGABadgeRelativeLayout(4)

     Android BGABadgeView:BGABadgeImageView以及BGABadgeRelativeLayout(4) 在附录文章5,6,7的基础上,写一个小例子说明BGABadge ...

  3. Android BGABadgeView:BGABadgeLinearLayout以整体线性布局作为BadgeView(3)

     Android BGABadgeView:BGABadgeLinearLayout以整体线性布局作为BadgeView(3) Android BGABadgeView不仅可以把某个View作为B ...

  4. Android BGABadgeView:显示提示数字(2)

     Android BGABadgeView:显示提示数字(2) 在附录文章3的基础上,对代码进行稍微改造,显示在红色小圆球内部显示数字,同时给红色小圆球通过可编程调控红色小圆球的整体外观,布局文件 ...

  5. Android系统 小米/三星/索尼 应用启动图标未读消息数(BadgeNumber)动态提醒

    http://www.51itong.net/android-badgenumber-9789.html Android系统 小米/三星/索尼 应用启动图标未读消息数(BadgeNumber)动态提醒 ...

  6. Android 高仿QQ滑动弹出菜单标记已读、未读消息

    在上一篇博客<Android 高仿微信(QQ)滑动弹出编辑.删除菜单效果,增加下拉刷新功能>里,已经带着大家学习如何使用SwipeMenuListView这一开源库实现滑动列表弹出菜单,接 ...

  7. 桌面图标未读消息(小米,sony,三星手机)

    新消息来了,在桌面的Laucher图标上显示新消息数 /** * 应用桌面图标未读消息显示工具类 * 只支持 小米,三星和索尼 */ public class BadgeUtil { final st ...

  8. Android中为图标加上数字--用于未读短信数提醒,待更新应用数提醒等

    本文属于原创,转载请著名出处:http://flysnow.iteye.com/blog/906770 写道 在我们开发一些如短消息.应用商店等应用时,会考虑在短消息的图标上加上未读短信的数量,在应用 ...

  9. [iOS微博项目 - 3.6] - 获取未读消息

    github: https://github.com/hellovoidworld/HVWWeibo   A.获取登陆用户未读消息 1.需求 获取所有未读消息,包括新微博.私信.@.转发.关注等 把未 ...

随机推荐

  1. Oracle10g修改数据库字符集

    Oracle10g修改字符集记录: 版本:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production 参考 ...

  2. iOS 集成银联支付(绕过文档的坑,快速集成)-转

    本文是投稿文章,作者:南栀倾寒当初集成支付宝的时候,觉得见了这么丑的代码,加上这么难找的下载地址,在配上几乎为零的文档,寒哥就要吐血了. 下午去集成银联,才知道血吐的早了. 下载地址:https:// ...

  3. [转]Walkthrough: Your First F# Program

    本文转自:http://msdn.microsoft.com/en-us/library/vstudio/dd233160(v=vs.100).aspx   Visual Studio 2010 in ...

  4. chart.js图表 传值问题

    php:         $json['status'] = ture;                $json['list']=implode(',',$data);                ...

  5. 窗体WINFORM

    窗体的事件:删除事件:先将事件页面里面的挂好的事件删除,再删后台代码里面的事件 Panel是一个容器 1.Label -- 文本显示工具Text:显示的文字取值.赋值:lable1.Text 2.Te ...

  6. pandas之groupby分组与pivot_table透视表

    zhuanzi: https://blog.csdn.net/qq_33689414/article/details/78973267 pandas之groupby分组与pivot_table透视表 ...

  7. 解决hibernate对Sql Server分页慢的问题

    一.hibernate分页 hibernate对MsSql的伪分页 分页是web项目中比不可少的一个功能,数据量大的时候不能全部展示必然要用到分页技术.相信大家对hibernate中的分页都不陌生: ...

  8. leetcode_865. Smallest Subtree with all the Deepest Nodes

    https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/ 给定一颗二叉树,输出包含所有最深叶子结点的最小子树 ...

  9. jQuery radio 选中提示

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. php 阿里云短信验证码

    阿里云短信服务:https://dysms.console.aliyun.com 1.准备 1.1.创建签名.模板 1.2.创建.使用阿里云秘钥 地址:https://usercenter.conso ...