实现一个类似Chrome新功能提示的popoup
先让我们看一下Chrome的popup是什么样的:
这个“直接搜索网页”与“在打开的标签页之间切换”就是两个功能导航,还做了一个动画效果,会不停的上下晃。
我通过WindowManager的addView也实现了一个类似的效果,如下图:
主要是通过PopupWindow添加一个的view实现的。这个View代码如下:
public class PopupView extends RelativeLayout { public PopupView(Context context) {
super(context);
LayoutInflater inflater = LayoutInflater.from(context);
inflater.inflate(R.layout.pup_up_full_layout, this);
} @Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
Context context = getContext();
Animation anim = AnimationUtils.loadAnimation(context, R.anim.popup_animation);
View view = findViewById(R.id.notification);
Resources res = context.getResources();
Drawable background = res.getDrawable(R.drawable.bubble);
// 图片底色为白色,需要加滤镜,green为自己定义的颜色
background.setColorFilter(res.getColor(R.color.green), PorterDuff.Mode.SRC_ATOP);
view.setBackground(background);
// 增加动画
view.startAnimation(anim);
}
}
布局文件pup_up_full_layout.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" > <TextView
android:id="@+id/notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="top"
android:layout_marginRight="15dp"
android:drawableTop="@drawable/bubble_point_green"
android:text="@string/new_feature" /> </RelativeLayout>
动画文件popup_animation.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" > <translate
android:duration="1000"
android:fromYDelta="-89.5%p"
android:toYDelta="-89%p"
android:repeatCount="infinite"
android:repeatMode="reverse" /> </set>
实现一个类似Chrome新功能提示的popoup的更多相关文章
- 一个类似indexOf()的功能的函数
之前面试的时候遇到了这样的一道题,不过写的时候有些细节没注意到,现在重新写了一下. 写一个类似indexOf()的功能的函数 var str = "dafdfgvdahjfbhyuyvtur ...
- python如何实现一个类似重载的功能
def post(): print("this is post") print("想不到吧") class Http(): @classmethod def g ...
- Red Hat Enterprise Linux 7的新功能
简介红帽最新版本的旗舰平台交付显著增强的可用性. 性能和可靠性. 丰富的新功能为架构. 系统管理员和开发人员提供所需的资源以更高效地进行创新和管理.架构师: 红帽® 企业 Linux® 7 适合 ...
- ios实现类似魔兽小地图功能 在
写了一个类似魔兽小地图功能的控件. 比如你有一个可以放大缩小的scrollView.会在里面进行一些放大缩小,点击里面的按钮呀,等操作. 这个小地图控件.就会和你的大scrollView同步.并有缩略 ...
- Windows 11,一个新功能,一场新屠杀
6月24日,微软正式公布了新一代操作系统:Windows 11.这次的更新距离上一代操作系统Windows 10的发布,隔了有6年之久. 在新一代的操作系统中,包含了这些亮点: 采用了全新的UI设计. ...
- 一个新人如何学习在大型系统中添加新功能和Debug
文章背景: 今年七月份正式入职,公司主营ERP软件,楼主所在的组主要负责二次开发,使用的语言是Java. 什么叫二次开发呢?ERP软件的客户都是企业.而这些企业之间的情况都有所不同,一套标准版本的企业 ...
- 使用jQuery实现一个类似GridView的编辑,更新,取消和删除的功能
先来看看下面实时效果演示: 用户点击编辑时,在点击行下动态产生一行.编辑铵钮变为disabled.新产生的一行有更新和取消的铵钮,点击“取消”铵钮,删除刚刚动态产生的行.编辑铵钮状态恢复. 更新与删除 ...
- Rendertron:谷歌 Chrome 新的 headless 模式又贡献了一个新的技巧
摘自:https://zhuanlan.zhihu.com/p/31670033 Rendertron:JavaScript Web 富应用的一个老问题是如何使这些页面的动态渲染部分可供搜索引擎检索. ...
- Array.forEach原理,仿造一个类似功能
Array.forEach原理,仿造一个类似功能 array.forEach // 设一个arr数组 let arr = [12,45,78,165,68,124]; let sum = 0; // ...
随机推荐
- 磁盘镜像分析工具TSK
磁盘镜像分析工具TSK TSK(The Sleuth Kit)是一款基于命令行的数字取证工具集,用于分析磁盘镜像.该工具支持常见的各种文件系统,如Ext2/Ext3/Ext4.Fat/exFat. ...
- javascript入门教程笔记
BOM BOM 是“ Browser Object Model ”的缩写,简称“ 浏览器对象模型 ”. BOM 定义了 JavaScript 操作浏览器的接口,提供了访问某些功能(如浏览器窗口大小.版 ...
- hdu1028 Ignatius and the Princess III(生成函数整理占坑)upd 已咕
先咕着 ---------------2018 5 22---------------------- 题解 生成函数处理整数拆分 code #include<cstdio> #includ ...
- bzoj 2724 在线区间众数
如果不是在线,就是裸的莫队. 但这道题要求在线,然后就不会了.. 标程: http://hi.baidu.com/__vani/item/ecc63f3527395283c2cf2945 算法主要是分 ...
- bzoj 4836: [Lydsy2017年4月月赛]二元运算 -- 分治+FFT
4836: [Lydsy2017年4月月赛]二元运算 Time Limit: 8 Sec Memory Limit: 128 MB Description 定义二元运算 opt 满足 现在给定一 ...
- NOIP200606金明的预算方案
试题描述: 金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间金明自己专用的很宽敞的房间.更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过N元钱就行”. ...
- php uncode 转汉字编码
$test = "%u4E0A%u6D77%u9EC4%u6D66";//$test = '\u5e86\u91cd\u5e86'; //庆重庆$temp = explode('% ...
- python开发_counter()
在python的API中,提到了Counter,它具有统计的功能 下面是我做的demo: 1.统计自定义字符串中每个字符出现的次数 2.读取一个文件,把文件中的内容转化为字符串,统计该字符串中每个字符 ...
- Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率DP
D. Bad Luck Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/pr ...
- Codeforces Round #300 A. Cutting Banner 水题
A. Cutting Banner Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/pro ...