首先定义显示效果的动画文件:

[html] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <setxmlns:android="http://schemas.android.com/apk/res/android">
  3. <translate
  4. android:fromXDelta="0"
  5. android:toXDelta="0"
  6. android:fromYDelta="120"
  7. android:toYDelta="0"
  8. android:duration="500"/>
  9. </set>

然后定义消失效果的动画文件:

[html] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <setxmlns:android="http://schemas.android.com/apk/res/android">
  3. <translate
  4. android:fromXDelta="0"
  5. android:toXDelta="0"
  6. android:fromYDelta="0"
  7. android:toYDelta="120"
  8. android:duration="500"/>
  9. </set>

PopupWindow的动画显示效果是通过setAnimationStyle(int id) 方法设置的,其中id为一个style的id,所以我们要在styles.xml文件中设置一个动画样式:

[html] view plain copy
  1. <stylename="popwin_anim_style">
  2. <itemname="android:windowEnterAnimation">@anim/menushow</item>
  3. <itemname="android:windowExitAnimation">@anim/menuhide</item>
  4. </style>

然后在程序中为PopupWindow设置就成:

[java] view plain copy
  1. PopupWindowpop=newPopupWindow(view,ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
  2. pop.setAnimationStyle(R.style.popwin_anim_style);

转自:http://blog.csdn.net/starrexstar/article/details/7896835


更多相关文章

  1. Android之GridView视图实现
  2. Android动态加载轮播图BannerView
  3. Android启动找不到activity问题
  4. android paint画笔 设置透明度setAlpha及 canvas画布
  5. 底部导航栏中间凸出效果
  6. android几种数据存储方式
  7. Android(安卓)Gradle开发
  8. Android(安卓)---模拟手机发送短信
  9. 【转】Android开发=》打开系统设置(信息)界面

随机推荐

  1. Android通知Notification
  2. 【Android】定义HttpPost连接超时
  3. Android向桌面添加快捷方式,使其指向特定
  4. android联系人过滤
  5. android 自定义组件随着手指自动画圆
  6. android MediaRecorder录音
  7. android网络状态检查
  8. android中opengl es基本方法使用说明
  9. Android vlc 简单使用
  10. Dialog弹出后 Activity蒙层效果代码