你好,游客 登录 注册 搜索
背景:
阅读新闻

Android实现界面组件的抖动效果

[日期:2012-07-14] 来源:Linux社区  作者:t12x3456 [字体:大 中 小]

Android实现界面组件的抖动效果采用的Animation动画, 在系统提供的API Demos:

目录为  \android-sdk\samples\android-8\ApiDemos 中已经实现了简单的抖动效果 :

具体使用如下:

第一步:准备两个动画效果的XML文件,加入到 res/anim/目录下:

Shake.xml文件:

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0"
    android:toXDelta="10"
    android:duration="1000"
    android:interpolator="@anim/cycle_7" />

cycle_7.xml文件:

<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
    android:cycles="7" />

第二步: //代码使用动画效果: 

        Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);//加载动画资源文件
        findViewById(R.id.xxxx).startAnimation(shake); //给组件播放动画效果

linux
相关资讯       Android编程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款