最近由于项目需要,一直在寻找一个弹出窗口,在另一个弹出窗口弹出时,推上去的效果,居然找不到,经过不懈的努力,终于实现了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 更新时动画的实现,可实现一个窗口被一个窗口推上去的效果的更多相关文章

  1. 数据可视化(8)--D3数据的更新及动画

    最近项目组加班比较严重,D3的博客就一拖再拖,今天终于不用加班了,赶紧抽点时间写完~~ 今天就将D3数据的更新及动画写一写~~ 接着之前的博客写~~ 之前写了一个散点图的例子,下面可以自己写一个柱状图 ...

  2. SQL Server 统计信息更新时采样百分比对数据预估准确性的影响

    为什么要写统计信息 最近看到园子里有人写统计信息,楼主也来凑热闹. 话说经常做数据库的,尤其是做开发的或者优化的,统计信息造成的性能问题应该说是司空见惯. 当然解决办法也并非一成不变,“一招鲜吃遍天” ...

  3. 用C3中的animation和transform写的一个模仿加载的时动画效果

    用用C3中的animation和transform写的一个模仿加载的时动画效果! 不多说直接上代码; html标签部分 <div class="wrap"> <h ...

  4. 【Android环境搭建】解决安装使用SDK Manager更新时的问题

    问题描述: 安装使用SDK Manager更新时出现问题 Failed to fetch URL  https://dl-ssl.google.com/android/repository/repos ...

  5. SQL SERVER 2008 R2 SP1更新时,遇上共享功能更新失败解决方案

    SQL SERVER 2008 R2 SP1更新时,遇上共享功能更新失败的问题,可作如下尝试: 更新失败后,在windows的[事件查看器→应用程序]中找到来源为MsiInstaller,事件ID为1 ...

  6. Linux/CentOS配置:使用yum update更新时不升级内核的方法

    RedHat/CentOS/Fedora使用 yum update 更新时,默认会升级内核.但有些服务器硬件(特别是组装的机器)在升级内核后,新的内核可能会认不出某些硬件,要重新安装驱动,很麻烦.所以 ...

  7. Android开发配置,消除SDK更新时的“https://dl-ssl.google.com refused”异常

    消除SDK更新时的“https://dl-ssl.google.com refused”错误 消除SDK更新时,有可能会出现这样的错误:Download interrupted: hostname i ...

  8. checking在浏览器为应用缓存查找更新时触发

    离线的Web应用,就是在设备不能上网的时候还能运行应用.html5把离线应用作为重点,主要是开发人员的心愿.离线应用的开发的步骤有:首先应该知道设备是否能够上网;然后应该还能访问一定的资源(如图像.C ...

  9. 关于SVN更新时文件加锁的小结

    今天使用SVN更新应用,出现了下面的问题: update D:/workspace/acode/resource/springconf -r 6622 --force    Attempted to ...

随机推荐

  1. String 的 intern() 方法解析

    一.概述 JDK7 之前和之后的版本,String 的 intern() 方法在实现上存在差异,本文的说明环境是 JDK8,会在文末说明 intern() 方法的版本差异性. intern() 方法是 ...

  2. GitHub Actions 工作流

    今天打开github上面的 项目 突然 一个github actions 的提示, 进去后显示: 由于项目是Maven 创建的 选择Maven 进入:  初步看到代码:  大概意思就是 我们push ...

  3. 理解MVVM在react、vue中的使用

    理解MVVM在react.vue中的使用 一:什么是MVC.为什么不用MVC 1:MVC的含义: M(modal):是应用程序中处理数据逻辑的部分. V (view)  :是应用程序中数据显示的部分. ...

  4. 整理h5移动端适配方案

    <使用Flexible实现手淘H5页面的终端适配>:https://github.com/amfe/article/issues/17 <再聊移动端页面的适配>:https:/ ...

  5. TortoiseGit 保存账号密码

    TortoiseGit下载网址:http://download.tortoisegit.org/tgit/ 修改.gitconfig .gitconfig 用于记录git配置信息 路径:系统盘:\Us ...

  6. C# 使用System.Media.SoundPlayer播放wav格式的声音文件

    using System.Media; string szPath = Application.StartupPath + “\\SoundFile\\sound.wav”; SoundPlayer ...

  7. amazon爬取流程与思路

    第一步:访问分类页面 https://www.amazon.in//gp/site-directory?ref=nav_em_ajax_fail #抓包获得 第二步:获取分类页面下各个分类的url 如 ...

  8. Toggle the WinForms Ribbon Interface 切换 WinForms 功能区界面

    In this lesson, you will learn how to enable/disable the Ribbon User Interface in your application. ...

  9. Android 程序分析环境搭建-动态分析环境搭建

    静态查看过app 的代码,但是有些app 非常复杂,页面好多,你根本找不到从何处下手.还有app 通过静态分析,发现有被加固(后续会讲如何砸壳),根本找不到,还有即便你搜索app界面上的文字,你也搜索 ...

  10. InnoDB On-Disk Structures(三)--Tablespaces (转载)

    转载.节选于 https://dev.mysql.com/doc/refman/8.0/en/innodb-tablespace.html This section covers topics rel ...