Android 灵动菜单动画效果
来源:互联网 发布:java并发 编辑:程序博客网 时间:2024/04/27 23:12
通过ObjectAnimator实现一个灵活的菜单
public class PropertyTest extends Activity implements View.OnClickListener {private int[] mRes = { R.id.imageView_a, R.id.imageView_b,R.id.imageView_c, R.id.imageView_d, R.id.imageView_e };private List<ImageView> mImageViews = new ArrayList<ImageView>();private boolean mFlag = true;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.property);for (int i = 0; i < mRes.length; i++) {ImageView imageView = (ImageView) findViewById(mRes[i]);imageView.setOnClickListener(this);mImageViews.add(imageView);}}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.imageView_a:if (mFlag) {startAnim();} else {closeAnim();}break;default:Toast.makeText(PropertyTest.this, "" + v.getId(),Toast.LENGTH_SHORT).show();break;}}@SuppressLint("NewApi")private void closeAnim() {ObjectAnimator animator0 = ObjectAnimator.ofFloat(mImageViews.get(0),"alpha", 0.5F, 1F);ObjectAnimator animator1 = ObjectAnimator.ofFloat(mImageViews.get(1),"translationY", 200F, 0);ObjectAnimator animator2 = ObjectAnimator.ofFloat(mImageViews.get(2),"translationX", 200F, 0);ObjectAnimator animator3 = ObjectAnimator.ofFloat(mImageViews.get(3),"translationY", -200F, 0);ObjectAnimator animator4 = ObjectAnimator.ofFloat(mImageViews.get(4),"translationX", -200F, 0);AnimatorSet set = new AnimatorSet();set.setDuration(500);set.setInterpolator(new BounceInterpolator());set.playTogether(animator0, animator1, animator2, animator3, animator4);set.start();mFlag = true;}@SuppressLint("NewApi")private void startAnim() {ObjectAnimator animator0 = ObjectAnimator.ofFloat(mImageViews.get(0),"alpha", 1F, 0.5F);ObjectAnimator animator1 = ObjectAnimator.ofFloat(mImageViews.get(1),"translationY", 200F);ObjectAnimator animator2 = ObjectAnimator.ofFloat(mImageViews.get(2),"translationX", 200F);ObjectAnimator animator3 = ObjectAnimator.ofFloat(mImageViews.get(3),"translationY", -200F);ObjectAnimator animator4 = ObjectAnimator.ofFloat(mImageViews.get(4),"translationX", -200F);AnimatorSet set = new AnimatorSet();set.setDuration(500); // 插值器使用弹跳效果 set.setInterpolator(new BounceInterpolator());set.playTogether(animator0, animator1, animator2, animator3, animator4);set.start();mFlag = false;}}xml部分:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView_b" android:src="@drawable/b" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView_c" android:src="@drawable/c" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView_d" android:src="@drawable/d" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView_e" android:src="@drawable/e" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView_a" android:src="@drawable/a" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /></RelativeLayout>
0 0
- Android 灵动菜单动画效果
- Android属性动画——实现灵动菜单效果
- Android动画之灵动菜单
- Android 动画-->灵动菜单、计时器动画、下拉展开动画
- 灵动的菜单展开效果
- android 动画实现侧滑菜单效果
- Android 毛玻璃效果弹出菜单动画
- HTML5+CSS3 做一个灵动的动画 TAB 切换效果
- 菜单,圆周菜单 动画效果
- Android动画开发——Animation显示隐藏菜单效果
- Android动画开发——Animation显示隐藏菜单效果
- Android 属性动画实现的扇形菜单效果
- Android播放器菜单的显示隐藏动画效果
- android 动画效果2 仿老版本youku菜单效果 (巩固自己的动画知识)
- Jquery 下拉菜单动画效果
- 仿扇形菜单动画效果
- 仿扇形菜单动画效果
- Android中侧滑菜单效果实现(主界面和菜单界面实现平移、缩放、滚动动画)
- 文件操作以及实现文件的复制操作并且在目的目录创建相应文件夹
- canvas.drawText文字居中(备忘)
- Visual Studio 2013的Browser Link功能的使用,忽略js异常
- Linux下Mysql5.6版本安装日志
- 《剑指offer》变态跳台阶
- Android 灵动菜单动画效果
- 递归删除
- 监控自己APP的http/https网络请求的地址和请求耗时
- app的调试环境和正式环境的微信分享id
- SpringMVC接收和返回JSON数据
- Mac 输入法候选词框消失的解决方法
- TFS管理工具
- 兼容各种主流浏览器的CSS阴影效果
- easyui dataGrid 动态添加列