之前有朋友问我消息提醒咋实现,我一直没有整理出来,今天就放出来.微信朋友圈的消息提醒就是收到朋友的评论后背景底部显示消息条数和评论用户,顶部是一张相册背景和当前用户昵称头像。

1.消息提醒的布局如下:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"><ImageViewandroid:id="@+id/iv_bg"android:layout_width="0dp"android:layout_height="@dimen/public_200dp"android:background="@mipmap/ic_pic"android:scaleType="centerCrop"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toTopOf="parent" /><androidx.cardview.widget.CardViewandroid:id="@+id/cl_user"android:layout_width="@dimen/public_60dp"android:layout_height="@dimen/public_60dp"android:layout_marginRight="@dimen/public_20dp"app:cardCornerRadius="@dimen/public_5dp"app:cardElevation="0dp"app:layout_constraintBottom_toBottomOf="@+id/iv_bg"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toBottomOf="@+id/iv_bg"><ImageViewandroid:id="@+id/iv_user"android:layout_width="@dimen/public_60dp"android:layout_height="@dimen/public_60dp"android:background="@drawable/nim_avatar_default"android:scaleType="fitXY"tools:ignore="MissingConstraints" /></androidx.cardview.widget.CardView><TextViewandroid:id="@+id/tv_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginRight="@dimen/public_10dp"android:ellipsize="end"android:maxLines="1"android:paddingTop="@dimen/public_5dp"android:shadowColor="#999666"android:shadowDx="3"android:shadowDy="3"android:shadowRadius="1"android:textColor="#ffffff"android:textSize="@dimen/text_size_14sp"app:layout_constraintRight_toLeftOf="@+id/cl_user"app:layout_constraintTop_toTopOf="@+id/cl_user"android:text="今天很开心" /><androidx.constraintlayout.widget.ConstraintLayoutandroid:id="@+id/cl_message"android:layout_width="@dimen/public_140dp"android:layout_height="@dimen/public_40dp"android:layout_centerHorizontal="true"android:layout_marginTop="@dimen/public_10dp"android:layout_marginBottom="10dp"android:background="@drawable/message_bg"android:paddingLeft="@dimen/public_10dp"android:paddingRight="@dimen/public_10dp"android:visibility="gone"app:layout_constraintLeft_toRightOf="parent"app:layout_constraintRight_toLeftOf="parent"app:layout_constraintTop_toBottomOf="@+id/cl_user"><ImageViewandroid:id="@+id/message_avatar"android:layout_width="30dp"android:layout_height="30dp"android:src="@drawable/nim_avatar_default"app:layout_constraintBottom_toTopOf="parent"app:layout_constraintTop_toBottomOf="parent" /><TextViewandroid:id="@+id/message_detail"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="@dimen/public_6dp"android:text=""android:textColor="@color/white"android:textSize="@dimen/text_size_14sp"app:layout_constraintBottom_toTopOf="parent"app:layout_constraintLeft_toRightOf="@+id/message_avatar"app:layout_constraintTop_toBottomOf="parent" /></androidx.constraintlayout.widget.ConstraintLayout><androidx.constraintlayout.widget.ConstraintLayoutandroid:id="@+id/cl_photo"android:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="@dimen/public_20dp"android:paddingTop="@dimen/public_10dp"android:paddingBottom="@dimen/public_10dp"android:visibility="gone"app:layout_constraintTop_toBottomOf="@+id/cl_message"><TextViewandroid:id="@+id/tv_time"android:layout_width="0dp"android:layout_height="wrap_content"android:gravity="center_vertical"android:text="今天"android:textColor="@color/black"android:textSize="24sp"android:textStyle="bold" /><ImageViewandroid:id="@+id/iv_photo"android:layout_width="@dimen/public_75dp"android:layout_height="@dimen/public_75dp"android:layout_marginLeft="@dimen/public_12dp"android:src="@mipmap/icon_photo"app:layout_constraintLeft_toRightOf="@+id/tv_time"app:layout_constraintTop_toTopOf="@+id/tv_time" /></androidx.constraintlayout.widget.ConstraintLayout></androidx.constraintlayout.widget.ConstraintLayout>

2.布局截图:

3.Activity代码:

/*** 设置adapter*/
private void initAdapter() {View headCircle = LayoutInflater.from(MainActivity.this).inflate(R.layout.item_circle_head, null);initHead(headCircle);circleAdapter = new CircleAdapter(dataBeans, imageWatcher, llComment, etComment, this);layoutManger = new ScrollSpeedLinearLayoutManger(this);recyclerView.setLayoutManager(layoutManger);layoutManger.setSpeedSlow();circleAdapter.addHeaderView(headCircle);recyclerView.addItemDecoration(new SpaceDecoration(this));recyclerView.setAdapter(circleAdapter);
}
/*** 初始化消息提醒布局* @param headCircle*/
private void initHead(View headCircle) {ivBg = headCircle.findViewById(R.id.iv_bg);ivUser = headCircle.findViewById(R.id.iv_user);tvName = headCircle.findViewById(R.id.tv_name);clMessage = headCircle.findViewById(R.id.cl_message);ivMessage = headCircle.findViewById(R.id.message_avatar);tvMessage = headCircle.findViewById(R.id.message_detail);ivBg.setOnClickListener(this);ivUser.setOnClickListener(this);
//这里是调用接口数据,本例子写的假数据,小伙伴们可以根据自己需求来写,在拍照或者点击用户头像去个人中心在返回朋友圈列表时要   刷新消息提醒数据,用rxbus或者onActivityResult都可以。clMessage.setVisibility(View.VISIBLE);tvMessage.setText("10条新信息");
}

4.实现的完整效果图如下:

5.以上就是实现仿微信朋友圈的消息提醒功能,主要是布局和收到消息后刷新列表,后面会实现图片选择和拍照发送朋友圈功能。欢迎小伙伴们前来谈论,给出更好的方案,我加以改正.

项目源码地址:ExpandTextView: 实现仿微信朋友圈列表多类型布局,图片点击放大、保存,包含点赞、评论、消息提醒、视频播放等功能

Android仿微信朋友圈6之实现消息提醒功能相关推荐

  1. android 仿微信朋友圈 评论,2020年android 仿微信朋友圈 评论

    2020年android 仿微信朋友圈 评论 1.如果有人问我:那些艰难的岁月你是怎么熬过来的?我想我只有一句话回答:我有一种强大的精神力量支撑着我,这种力量名字叫"想死又不敢" ...

  2. Android自定义弹窗模仿微信,Android 仿微信朋友圈点赞和评论弹出框功能

    本文简单模仿微信朋友圈的点赞和评论弹出框,布局等细节请忽略,着重实现弹出框.发评论,及弹出位置的控制. 1. 微信弹出框 微信朋友圈的点赞和评论功能,有2个组成部分: 点击左下角的"更多&q ...

  3. android 微信朋友圈 全功能,Android仿微信朋友圈文字展开全文功能 Android自定义TextView仿微信朋友圈文字展开全文功能...

    Android自定义TextView仿微信朋友圈文字信息,展开全文功能 代码及注释如下: 首先写一个xml文件 showmore.xml: android:orientation="vert ...

  4. Android仿微信朋友圈发图片和文字

    Android仿微信朋友圈发图片和文字的一个开源项目,其在github上的项目主页是:https://github.com/zhangphil/FangWeiXinPengYouQuanFaTuPia ...

  5. Android 仿微信朋友圈添加图片

    github地址(欢迎下载Demo) https://github.com/zhouxu88/WXCircleAddPic 老习惯,先上图,着急用的朋友,直接带走Demo,先拿来用吧,毕竟老板催的紧, ...

  6. Android仿微信朋友圈7实现点赞功能

    前言: 之前一直有朋友问我点赞怎么实现?今天趁着休息时间整理出来,其实点赞的功能和用户评论差不多,都是显示一个用户列表,只不过评论有评论内容和回复评论功能.实现点赞的思路如下: 1.当用户点击点赞按钮 ...

  7. Android仿微信朋友圈4实现评论动态时输入框和软键盘自动定位到内容下面

    最近做完朋友圈功能后,测试提出一个功能优化,在某些发布的动态下评论时软键盘和输入框遮当内容了,这个用户体验感觉不是很好,于是根据今日头条和其他热门的App评论时软键盘和输入框都是在内容下面.Scrol ...

  8. Android仿微信朋友圈2自定义点赞评论弹框

    最近在做类似微信朋友圈点赞评论的功能,有个点赞评论弹框交互,感觉效果很好,点击评论按钮弹框从按钮左边弹出,遇到了3个问题(弹出动画不对.弹框布局没有适配.弹出的位置显示不对),动画和布局好解决,弹出的 ...

  9. Android仿微信朋友圈3评论输入框及点击外部和列表滑动时隐藏输入框和键盘解决方法

    接着上一篇的评论点赞弹框之后,这次来说说微信的评论输入框,点击屏幕外部评论框和键盘消失,滑动列表时输入框和键盘也要消失,这里不是说一定要舔微信啥的,只是单纯从技术角度出发,分析原理和实现,解决我们自己 ...

最新文章

  1. mysql数据库备份还原
  2. tf.expand_dims() 的用法
  3. 潘建伟团队首次实现18个光量子比特纠缠,刷新世界记录
  4. navicat for mysql 显示中文乱码解决办法
  5. 网页上的图片怎么提取出来_如何在网站上提取图片素材
  6. 学习SPI的一些疑惑
  7. 常见问题_数组索引越界异常
  8. 在Java中从字符串转换为双精度
  9. 如何使用 Laravel Facades ?
  10. Mac下安装Fiddler抓包工具(别试了,会报错,没办法使用)
  11. 【运动学】基于matlab GUI模拟小球自由落体【含Matlab源码 1630期】
  12. 在android下使用i2c tools
  13. 金蝶K3 SQL报表系列-BOM成本明细表
  14. php ip 库,php IP获取城市API(纯真IP数据库)
  15. html5音乐播放器网页底部,jQuery+html5网页底部固定mp3音乐播放器代码
  16. 编码器/译码器(Verilog HDL)|计算机组成
  17. WeOpen Talk|张亮:正确理解开源的意义,迸发开源潜力
  18. 话费充值api接口 手机话费充值功能接入
  19. [ZGC升级记录](to-space exhausted/Evacuation Failure)
  20. 中华小子剧情介绍,中华小子在线观看

热门文章

  1. USB C应该简化我们的生活,而不是一团糟
  2. 基于selenium的斗鱼直播房间详细信息自动化爬虫
  3. 沈阳化工股份有限公司发生闪爆 致4人死亡(图)
  4. Dreamweaver 2021全新版本带来更强大的网页设计能力
  5. Python打包(问题记录,待解决)
  6. Praat脚本-033 | Praat脚本裁剪归整句中停顿
  7. 《天河传说》详细攻略2
  8. GitHub创建项目的流程
  9. Github创建项目步骤
  10. Vue超实用案例2:使用setInterval实现逐字动态输入