android 仿微信demo————微信启动界面实现

android 仿微信demo————注册功能实现(移动端)

android 仿微信demo————注册功能实现(服务端)

android 仿微信demo————登录功能实现(移动端)

android 仿微信demo————登录功能实现(服务端)

android 仿微信demo————微信主界面实现

android 仿微信demo————微信消息界面实现(移动端)

android 仿微信demo————微信消息界面实现(服务端)

android 仿微信demo————微信通讯录界面功能实现(移动端,服务端)

android 仿微信demo————微信发现界面实现

android 仿微信demo————微信顶部操作栏界面实现

android 仿微信demo————微信顶部操作栏搜索按钮实现(查询通讯录好友功能)

android 仿微信demo————微信顶部操作栏加号按钮实现(弹出子菜单)

上一篇中实现微信顶部操作栏搜索按钮,这一篇完善加号按钮功能

源码获取点我,记得给个start哦

微信顶部操作栏加号按钮实现(弹出子菜单)

我们之前说过加号按钮可以通过toolbar的overflow实现,但是效果不理想,那么要实现微信那种效果,要怎么做呢?

有没有发现当点击加号后的弹出子菜单像不像我们之前在登录界面做的对话框有点类似,没错,可以对话框实现,我们可以自定义一个对话框,当点击加号按钮时便弹出一个对话框

创建对话框activity
MainTopRightDialog.java

package com.zhang.test.wxchatdemo1;import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;public class MainTopRightDialog extends Activity {private LinearLayout layout;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main_top_right_dialog);//设置对话框activity的宽度等于屏幕宽度,一定要设置,不然对话框会显示不全getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);//需要添加的语句layout=(LinearLayout)findViewById(R.id.main_dialog_layout);layout.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {}});}@Overridepublic boolean onTouchEvent(MotionEvent event){finish();return true;}
}

创建对应的布局
main_top_right_dialog.xml

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginTop="46dp"><LinearLayoutandroid:id="@+id/main_dialog_layout"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentTop="true"android:layout_alignParentRight="true"android:background="@drawable/title_function_bg"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><ImageViewandroid:id="@+id/imageView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:layout_marginLeft="8dp"android:src="@drawable/chat_img" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:padding="8dp"android:text="发起群聊"android:textColor="#fff"android:textSize="18sp" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><ImageViewandroid:id="@+id/imageView2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:layout_marginLeft="8dp"android:src="@drawable/add_friend_img" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:padding="8dp"android:text="添加朋友"android:textColor="#fff"android:textSize="18sp" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><ImageViewandroid:id="@+id/imageView3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:layout_marginLeft="8dp"android:src="@drawable/scan_scan_img" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:padding="8dp"android:text="扫一扫"android:textColor="#fff"android:textSize="18sp" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><ImageViewandroid:id="@+id/imageView4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:layout_marginLeft="8dp"android:src="@drawable/pay_img" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:padding="8dp"android:text="收付款"android:textColor="#fff"android:textSize="18sp" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><ImageViewandroid:id="@+id/imageView5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:layout_marginLeft="8dp"android:src="@drawable/help_img" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:padding="8dp"android:text="帮助与反馈"android:textColor="#fff"android:textSize="18sp" /></LinearLayout></LinearLayout></RelativeLayout>
</RelativeLayout>

在之前的文章说过activity是会覆盖已有的activity(界面),所有我们需要在AndroidMainfest.xml中给activity设置一个自定义对话框主题,转换为对话框

在AndroidMainfest.xml中把activity转换为对话框

在style.xml中声明自定义的对话框

    <style name="MyDialogStyleTop" parent="android:Theme.Dialog" ><item name="android:windowAnimationStyle">@style/AnimTop2</item><item name="android:windowFrame">@null</item><!--边框--><item name="android:windowIsFloating">true</item><!--是否浮现在activity之上--><item name="android:windowIsTranslucent">true</item><!--半透明--><item name="android:windowNoTitle">true</item><!--无标题--><item name="android:windowContentOverlay">@null</item><item name="android:windowBackground">@android:color/transparent</item><!--背景透明--><item name="android:backgroundDimEnabled">false</item><!--模糊--></style><style name="AnimTop2" parent="@android:style/Animation"><item name="android:windowEnterAnimation">@anim/push_top_in2</item><item name="android:windowExitAnimation">@anim/push_top_out2</item></style>

上面自定义的对话框样式继承Theme.Dialog转换为对话框,并且还给对话框设置动画属性,下面会给出这两个文件

创建动作文件anim


在动作文件中创建两个渐变尺寸伸缩动画效果scale文件

push_top_in2.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- 上下滑入式 -->
<scale   xmlns:android="http://schemas.android.com/apk/res/android"android:interpolator="@android:anim/accelerate_decelerate_interpolator"  android:fromXScale="1.0"   android:toXScale="1.0"   android:fromYScale="0"   android:toYScale="1.0"   android:pivotX="0"android:pivotY="10%"android:duration="200" />

push_top_out2.xml

<?xml version="1.0" encoding="utf-8"?><scale   xmlns:android="http://schemas.android.com/apk/res/android"android:interpolator="@android:anim/accelerate_decelerate_interpolator"  android:fromXScale="1.0"android:toXScale="1.0"   android:fromYScale="1.0"   android:toYScale="0"   android:pivotX="0"android:pivotY="10%"android:duration="200" />

测试

测试前要把之前点击加号按钮跳转的activity注释取消掉

android 仿微信demo————微信顶部操作栏加号按钮实现(弹出子菜单)相关推荐

  1. 导航栏鼠标悬浮弹出子菜单面板的实现方案

    当鼠标移动到导航栏某个字块时,悬浮出一块子菜单面板 实现: 在导航栏的字块镶嵌一块要悬浮的div,设置display为none. jquery设置字块鼠标悬浮mouseover的事件为:显示悬浮div ...

  2. android 仿微信demo————微信顶部操作栏界面实现

    android 仿微信demo----微信启动界面实现 android 仿微信demo----注册功能实现(移动端) android 仿微信demo----注册功能实现(服务端) android 仿微 ...

  3. android 仿微信demo————微信主界面实现

    android 仿微信demo----微信启动界面实现 android 仿微信demo----注册功能实现(移动端) android 仿微信demo----注册功能实现(服务端) android 仿微 ...

  4. android 仿微信demo————微信发现界面实现

    android 仿微信demo----微信启动界面实现 android 仿微信demo----注册功能实现(移动端) android 仿微信demo----注册功能实现(服务端) android 仿微 ...

  5. android 仿微信demo————微信消息界面实现(移动端)

    android 仿微信demo----微信启动界面实现 android 仿微信demo----注册功能实现(移动端) android 仿微信demo----注册功能实现(服务端) android 仿微 ...

  6. android 仿微信demo————微信通讯录界面功能实现(移动端,服务端)

    android 仿微信demo----微信启动界面实现 android 仿微信demo----注册功能实现(移动端) android 仿微信demo----注册功能实现(服务端) android 仿微 ...

  7. android 仿微信demo————微信消息界面实现(服务端)

    android 仿微信demo----微信启动界面实现 android 仿微信demo----注册功能实现(移动端) android 仿微信demo----注册功能实现(服务端) android 仿微 ...

  8. android 仿微信demo————微信启动界面实现

    android 仿微信demo----微信启动界面实现 android 仿微信demo----注册功能实现(移动端) android 仿微信demo----注册功能实现(服务端) android 仿微 ...

  9. android 仿QQ,微信群组里的@功能,支持@多人,并能一键删除,能获取上传对应的id(修改版)

    首先注明该文章是借签别人的博客,原文博文地址点击打开链接 android 仿QQ,微信群组里的@功能,支持@多人,并能一键删除,能获取上传对应的id 这个需求来源:本人做集成环信聊天时,项目需要@功能 ...

最新文章

  1. Python中使用librosa包进行mfcc特征参数提取
  2. 从向量的角度理解皮尔逊相关系数
  3. 【控制】《多智能体机器人系统信息融合与协调》范波老师-第6章-基于分布式强化学习的多 Agent 协调方法
  4. 叫你两招编辑PDF文档的方法
  5. python oj 输入_Python写OJ题时输入问题
  6. java $1参数_jmap命令详解----查看JVM内存使用详情
  7. char类型怎么输入 c语言_c语言入门(一)
  8. docker php 一键部署_提升10倍生产力:IDEA远程一键部署SpringBoot到Docker
  9. 软件单元测试数据分析模板,单元测试报告模板
  10. 安装oracle所有依赖包,安装oracle11g R2 缺少依赖包
  11. 转:创业者一手货:我是怎么在网上卖鱼的?
  12. web图片铺满网页_CSS实现网页背景图片自适应全屏
  13. 云服务器ecs是vps还是虚拟主机,云服务器ecs是vps还是虚拟主机
  14. oc总结第四讲:属性
  15. 普通本科菜菜海淘无人搭理,苦心闭关修炼一个月,出关后成功拿下阿里,蚂蚁金服,美团三个大厂意向书
  16. iOS开源项目MobileProject功能点介绍
  17. [USACO 2012 Feb B]Moo - 规律
  18. 互联网产品经理的职责范围、能力要求
  19. 数据中心与云数据中心
  20. 【第 01 章 基于直方图优化的图像去雾技术-全套系统MATLAB智能驾驶深度学习】

热门文章

  1. android开发环境类错误
  2. 计算机点击关机 重新启动,电脑点击关机却自动重启了怎么回事
  3. 计算机桌面弹窗,如何关闭电脑桌面弹出的广告
  4. 笔记本用了这么久,快捷键知多少?
  5. 学霸如何使用计算机,大学生对话高三毕业生:“黑科技”学霸是如何炼成的
  6. BERT |(2)BERT的原理详解
  7. 解决windows update 8024402C错误
  8. Android 10.0 Launcher3 电话和短信app图标显示未读短信和未接来电的条数
  9. GitHub项目分享:2021年5月精选项目推荐
  10. 推荐系统之LFM算法详解