免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1109 | 回复: 0
打印 上一主题 下一主题

android 动画效果 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-06-24 09:09 |只看该作者 |倒序浏览
实现窗口抖动

MainActivity.java
  1. package com.example.windowjitter;

  2. import android.app.Activity;
  3. import android.os.Bundle;
  4. import android.view.Menu;
  5. import android.view.View;
  6. import android.view.animation.Animation;
  7. import android.view.animation.AnimationUtils;
  8. import android.widget.Button;
  9. import android.widget.RelativeLayout;

  10. /**
  11. * ′°¿ú¶¶¶ˉ
  12. *
  13. * @author yand
  14. *
  15. */
  16. public class MainActivity extends Activity {

  17.     private RelativeLayout rel;
  18.     private Button btn;

  19.     @Override
  20.     protected void onCreate(Bundle savedInstanceState) {
  21.         super.onCreate(savedInstanceState);
  22.         setContentView(R.layout.activity_main);

  23.         rel = (RelativeLayout) this.findViewById(R.id.rel);
  24.         btn = (Button) this.findViewById(R.id.btn);
  25.         btn.setOnClickListener(new Button.OnClickListener() {
  26.             @Override
  27.             public void onClick(View v) {
  28.                 Animation anim = AnimationUtils.loadAnimation(
  29.                         MainActivity.this, R.anim.myanim);
  30.                 rel.startAnimation(anim);
  31.             }
  32.         });
  33.     }

  34.     @Override
  35.     public boolean onCreateOptionsMenu(Menu menu) {
  36.         getMenuInflater().inflate(R.menu.activity_main, menu);
  37.         return true;
  38.     }

  39. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP