先让我们看一下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的更多相关文章

  1. 一个类似indexOf()的功能的函数

    之前面试的时候遇到了这样的一道题,不过写的时候有些细节没注意到,现在重新写了一下. 写一个类似indexOf()的功能的函数 var str = "dafdfgvdahjfbhyuyvtur ...

  2. python如何实现一个类似重载的功能

    def post(): print("this is post") print("想不到吧") class Http(): @classmethod def g ...

  3. Red Hat Enterprise Linux 7的新功能

     简介红帽最新版本的旗舰平台交付显著增强的可用性. 性能和可靠性. 丰富的新功能为架构. 系统管理员和开发人员提供所需的资源以更高效地进行创新和管理.架构师: 红帽® 企业 Linux® 7 适合 ...

  4. ios实现类似魔兽小地图功能 在

    写了一个类似魔兽小地图功能的控件. 比如你有一个可以放大缩小的scrollView.会在里面进行一些放大缩小,点击里面的按钮呀,等操作. 这个小地图控件.就会和你的大scrollView同步.并有缩略 ...

  5. Windows 11,一个新功能,一场新屠杀

    6月24日,微软正式公布了新一代操作系统:Windows 11.这次的更新距离上一代操作系统Windows 10的发布,隔了有6年之久. 在新一代的操作系统中,包含了这些亮点: 采用了全新的UI设计. ...

  6. 一个新人如何学习在大型系统中添加新功能和Debug

    文章背景: 今年七月份正式入职,公司主营ERP软件,楼主所在的组主要负责二次开发,使用的语言是Java. 什么叫二次开发呢?ERP软件的客户都是企业.而这些企业之间的情况都有所不同,一套标准版本的企业 ...

  7. 使用jQuery实现一个类似GridView的编辑,更新,取消和删除的功能

    先来看看下面实时效果演示: 用户点击编辑时,在点击行下动态产生一行.编辑铵钮变为disabled.新产生的一行有更新和取消的铵钮,点击“取消”铵钮,删除刚刚动态产生的行.编辑铵钮状态恢复. 更新与删除 ...

  8. Rendertron:谷歌 Chrome 新的 headless 模式又贡献了一个新的技巧

    摘自:https://zhuanlan.zhihu.com/p/31670033 Rendertron:JavaScript Web 富应用的一个老问题是如何使这些页面的动态渲染部分可供搜索引擎检索. ...

  9. Array.forEach原理,仿造一个类似功能

    Array.forEach原理,仿造一个类似功能 array.forEach // 设一个arr数组 let arr = [12,45,78,165,68,124]; let sum = 0; // ...

随机推荐

  1. AOP的自动代理

    Spring的aop机制提供两类方式实现类代理.一种是单个代理,一种是自动代理. 单个代理通过ProxyFactoryBean来实现(就如上面的配置). 自动代理:自动代理能够让切面定义来决定那个be ...

  2. PHP视频教程 字符串处理函数(二)

    1.字符串输出:echo()输出一个或者多个字符串 2.截取 chunk_split(); 3.

  3. Process Explorer常用操作介绍

    (未获得作者本人同意,严禁转载) Process Explorer出现的背景 Process Explorer可以看成是一个加强版的任务管理器.在较早的Windows版本中,任务管理器提供的功能是非常 ...

  4. java switch

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha switch 是 开关:转换 的意思. 支持的数据类型 有 : 字节,字符,短整型,整型 ...

  5. Codeforces 980 D. Perfect Groups

    \(>Codeforces\space980 D. Perfect Groups<\) 题目大意 : 设 \(F(S)\) 表示在集合\(S\)中把元素划分成若干组,使得每组内元素两两相乘 ...

  6. [HNOI2012]集合选数 --- 状压DP

    [HNOI2012]集合选数 题目描述 <集合论与图论>这门课程有一道作业题,要求同学们求出\({1,2,3,4,5}\)的所有满足以 下条件的子集:若 x 在该子集中,则 2x 和 3x ...

  7. [BZOJ3514]CodeChef MARCH14 GERALD07加强版(LCT+主席树)

    3514: Codechef MARCH14 GERALD07加强版 Time Limit: 60 Sec  Memory Limit: 256 MBSubmit: 2177  Solved: 834 ...

  8. POJ3233 Matrix Power Series 矩阵乘法

    http://poj.org/problem?id=3233 挺有意思的..学习到结构体作为变量的转移, 题意 : 给定矩阵A,求A + A^2 + A^3 + ... + A^k的结果(两个矩阵相加 ...

  9. hdu 4027 Can you answer these queries? 线段树区间开根号,区间求和

    Can you answer these queries? Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/sho ...

  10. hihocoder155周 任务分配

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定 N 项任务的起至时间( S1, E1 ), ( S2, E2 ), ..., ( SN, EN ), 计算最少需要多 ...