andorid popupwindow 更新时动画的实现,可实现一个窗口被一个窗口推上去的效果
最近由于项目需要,一直在寻找一个弹出窗口,在另一个弹出窗口弹出时,推上去的效果,居然找不到,经过不懈的努力,终于实现了popupwindow在更新时的动画。
先上代码:
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.TextView; public class NotePopWindow extends PopupWindow {
private TextView mNodeTextView;
private Context mContext;
private ViewWrapper mWrapper; public NotePopWindow(Context context, int width, int height) {
super(LayoutInflater.from(context).inflate(R.layout.fullscreen_view_note_popwindow, null), width, height);
mContext = context;
setBackgroundDrawable(new BitmapDrawable());
setAnimationStyle(R.style.anim_note_bottombar);
initViews();
} public NotePopWindow(Context context) {
super(context); } public NotePopWindow(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
} private void initViews() {
mNodeTextView = (TextView) getContentView().findViewById(R.id.note_view);
mWrapper = new ViewWrapper(getContentView());
} @SuppressLint("NewApi")
public void startUpAnimation() {
ObjectAnimator translationRight = ObjectAnimator.ofInt(mWrapper, "Y", (int) mContext.getResources()
.getDimension(R.dimen.bottom_menu_window_height));
translationRight.setDuration(540);
translationRight.start();
} @SuppressLint("NewApi")
public void startDownAnimation() {
ObjectAnimator translationRight = ObjectAnimator.ofInt(mWrapper, "Y", 0);
translationRight.setDuration(360);
translationRight.start();
} private class ViewWrapper {
private View mTarget;
private boolean isUp = true; public ViewWrapper(View target) {
setmTarget(target);
} @SuppressWarnings("unused")
public int getY() {
if (isUp) {
isUp = false;
return 0; } else {
isUp = true;
return (int) mContext.getResources().getDimension(R.dimen.bottom_menu_window_height);
} } @SuppressWarnings("unused")
public void setY(int height) {
update(0, height, -1, -1);
} @SuppressWarnings("unused")
public View getmTarget() {
return mTarget;
} public void setmTarget(View mTarget) {
this.mTarget = mTarget;
}
}
}
实现原理其实就是依靠属性动画,但是属性动画只能作用于有set和get方法的属性,所以关键就是写一个包装类,提供属性的set和get方法,在set方法中调用popwindow的update方法,即可在update时实现动画。
讲的不是很清楚,代码如上,如果实在看不懂可以邮件、qq联系。。。
andorid popupwindow 更新时动画的实现,可实现一个窗口被一个窗口推上去的效果的更多相关文章
- 数据可视化(8)--D3数据的更新及动画
最近项目组加班比较严重,D3的博客就一拖再拖,今天终于不用加班了,赶紧抽点时间写完~~ 今天就将D3数据的更新及动画写一写~~ 接着之前的博客写~~ 之前写了一个散点图的例子,下面可以自己写一个柱状图 ...
- SQL Server 统计信息更新时采样百分比对数据预估准确性的影响
为什么要写统计信息 最近看到园子里有人写统计信息,楼主也来凑热闹. 话说经常做数据库的,尤其是做开发的或者优化的,统计信息造成的性能问题应该说是司空见惯. 当然解决办法也并非一成不变,“一招鲜吃遍天” ...
- 用C3中的animation和transform写的一个模仿加载的时动画效果
用用C3中的animation和transform写的一个模仿加载的时动画效果! 不多说直接上代码; html标签部分 <div class="wrap"> <h ...
- 【Android环境搭建】解决安装使用SDK Manager更新时的问题
问题描述: 安装使用SDK Manager更新时出现问题 Failed to fetch URL https://dl-ssl.google.com/android/repository/repos ...
- SQL SERVER 2008 R2 SP1更新时,遇上共享功能更新失败解决方案
SQL SERVER 2008 R2 SP1更新时,遇上共享功能更新失败的问题,可作如下尝试: 更新失败后,在windows的[事件查看器→应用程序]中找到来源为MsiInstaller,事件ID为1 ...
- Linux/CentOS配置:使用yum update更新时不升级内核的方法
RedHat/CentOS/Fedora使用 yum update 更新时,默认会升级内核.但有些服务器硬件(特别是组装的机器)在升级内核后,新的内核可能会认不出某些硬件,要重新安装驱动,很麻烦.所以 ...
- Android开发配置,消除SDK更新时的“https://dl-ssl.google.com refused”异常
消除SDK更新时的“https://dl-ssl.google.com refused”错误 消除SDK更新时,有可能会出现这样的错误:Download interrupted: hostname i ...
- checking在浏览器为应用缓存查找更新时触发
离线的Web应用,就是在设备不能上网的时候还能运行应用.html5把离线应用作为重点,主要是开发人员的心愿.离线应用的开发的步骤有:首先应该知道设备是否能够上网;然后应该还能访问一定的资源(如图像.C ...
- 关于SVN更新时文件加锁的小结
今天使用SVN更新应用,出现了下面的问题: update D:/workspace/acode/resource/springconf -r 6622 --force Attempted to ...
随机推荐
- mysql 排它锁之行锁、间隙锁、后码锁
MySQL InnoDB支持三种行锁定 行锁(Record Lock):锁直接加在索引记录上面,锁住的是key. 间隙锁(Gap Lock):锁定索引记录间隙,确保索引记录的间隙不变.间隙锁是针对事务 ...
- 一起学SpringMVC之文件上传
概述 在Web系统开发过程中,文件上传是普遍的功能,本文主要以一个简单的小例子,讲解SpringMVC中文件上传的使用方法,仅供学习分享使用,如有不足之处,还请指正. 文件上传依赖包 如下所示,文件上 ...
- Flutter学习笔记(26)--返回拦截WillPopScope,实现1秒内点击两次返回按钮退出程序
如需转载,请注明出处:Flutter学习笔记(26)--返回拦截WillPopScope,实现1秒内点击两次返回按钮退出程序 在实际开发中,为了防止用户误触返回按钮导致程序退出,通常会设置为在1秒内连 ...
- C++中的try throw catch 异常处理
今天在开发过程中调用一个库函数结果库函数有throw操作,当前代码没有对throw进行捕获操作,导致进程在main 函数中捕获到异常导致进程crash.所以借此记录下c++关于try,throw,ca ...
- http模块
1.引入http模块 const http = require('http') 2.创建node服务器 在创建node服务器的时候需要使用http模块中的http.creatServer()方法来进行 ...
- 如何在asm上定位数据块
转自 https://blogs.oracle.com/database4cn/%e5%a6%82%e4%bd%95%e5%9c%a8asm%e4%b8%8a%e5%ae%9a%e4%bd%8d%e6 ...
- 使用可移动表空间(TTS)的最佳做法 (Doc ID 1457876.1)
Best Practices for Using Transportable Tablespaces (TTS) (Doc ID 1457876.1) APPLIES TO: Oracle Datab ...
- CentOS高可用集群LVS+Keepalived(DR模式)
操作系统:CentOS6.5_x64 mini 负载均衡模式:DR(直接路由) LVS与Keepalived简述: LVS是Linux Virtual Server的简写,意即Linux虚拟服务器,是 ...
- docker alphine 设置系统日期
设置时区为上海 RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && ...
- node_modules/.bin/babel : 无法加载文件 D:\node\node_project\es6\node_modules\.bin\babel.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.co m/fwlink/?LinkID=135170 中的 about_Execution_Policies。
刚入门es6,遇到上面问题,然后 解决方案: 以管理员身份运行vs code执行:get-ExecutionPolicy,显示Restricted,表示状态是禁止的执行:set-ExecutionPo ...