先让我们看一下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. JSP中动态INCLUDE与静态INCLUDE的区别?

    动态INCLUDE用jsp:include动作实现 它总是会检查所含文件中的变化,适合用于包含动态页面,并且可以带参数 静态INCLUDE用include伪码实现,定不会检查所含文件的变化,适用于包含 ...

  2. 2017/11/9 Leetcode 日记

    2017/11/9 Leetcode 日记 566. Reshape the Matrix In MATLAB, there is a very useful function called 'res ...

  3. python 进程间通信(下)

    利用 Value,Array   先说明这个方法并不常用,因为有更灵活的方法 from multiprocessing import Process,Value,Array def f(n,a,not ...

  4. 51nod1981 如何愉快地与STL玩耍

    先摆官方题解吧......... ....................有什么好讲的呢....... 注意一些地方常数优化一下.......然后......$bitset$怎么暴力怎么来吧..... ...

  5. [CodeForces-440D]Berland Federalization

    题目大意: 给你一棵树,你可以删掉一些边,使得分除去的子树中至少有一棵大小为k. 问最少删去多少边,以及删边的具体方案. 思路: 树形DP. f[i][j]表示以i为根,子树中去掉j个点最少要删边的数 ...

  6. 启动Tensorboard时发生错误:class BeholderHook(tf.estimator.SessionRunHook): AttributeError: module 'tensorflow.python.estimator.estimator_lib' has no attribute 'SessionRunHook'

    报错:class BeholderHook(tf.estimator.SessionRunHook):AttributeError: module 'tensorflow.python.estimat ...

  7. 让你的chrome开发工具console支持jquery

    首先执行以下代码: ;(function(d,s){d.body.appendChild(s=d.createElement('script')).src='http://code.jquery.co ...

  8. 2015 UESTC 搜索专题A题 王之迷宫 三维bfs

    A - 王之迷宫 Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/61 Des ...

  9. Vue学习记录-初探Vue

    写在开头 2017年,部门项目太多,而且出现了一个现象,即:希望既要有APP,也能够直接扫码使用,也能放到微信公众号里面. 从技术角度来说,APP我们可以选择原生开发,也可以选择ReactNative ...

  10. ubuntu上安装systemtap

    http://www.cnblogs.com/hdflzh/archive/2012/07/25/2608910.html