Android 心跳动画

直接上代码 MainActivity
public class MainActivity extends AppCompatActivity {
private ImageView ivHart; //图片信息
AlphaAnimation alphaAnimation = null; //心跳动画
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ivHart = (ImageView) findViewById(R.id.ivHart);
shadeAnim(ivHart);
}
@Override
protected void onResume() {
super.onResume();
if (alphaAnimation != null) {
alphaAnimation.start();
}
}
@Override
protected void onPause() {
super.onPause();
if (alphaAnimation != null) {
alphaAnimation.cancel();
}
}
/**
* 心跳渐变动画
*
* @param view 执行该动画的view对象
*/
private void shadeAnim(View view) {
alphaAnimation = new AlphaAnimation(0.1f, 1.0f);
alphaAnimation.setDuration(2000);
alphaAnimation.setRepeatCount(-1);
alphaAnimation.setRepeatMode(Animation.REVERSE);
alphaAnimation.start();
view.setAnimation(alphaAnimation);
}
布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/yy"
tools:context="com.hanbao.myapplication.MainActivity"> <ImageView
android:id="@+id/ivHart"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/x"/> </RelativeLayout>
Android 心跳动画的更多相关文章
- Android属性动画
这几天看郭神的博客 Android属性动画完全解析(上),初识属性动画的基本用法之后,我自己突然想实现一种动画功能,就是我们在携程网.阿里旅行等等手机APP端买火车票的时候,看到有选择城市,那么就有出 ...
- android 自定义动画
android自定义动画注意是继承Animation,重写里面的initialize和applyTransformation,在initialize方法做一些初始化的工作,在applyTransfor ...
- 【转】android 属性动画之 ObjectAnimator
原文网址:http://blog.csdn.net/feiduclear_up/article/details/39255083 前面一篇博客讲解了 android 简单动画之 animtion,这里 ...
- Android属性动画之ValueAnimation
ValueAnimation是ObjectAnimation类的父类,经过前几天的介绍,相信大家对ObjectAnimation有了 一定的认识,今天就为大家最后介绍一下ValueAnimation, ...
- Android属性动画之ObjectAnimator
相信对于Android初学者,对于Android中的动画效果一定很感兴趣,今天为大家总结一下刚刚学到的属性动画案例. 首先和一般的Android应用一样,我们先建一个工程,为了方便,我们的布局文件中就 ...
- 79.Android之动画基础
转载:http://a.codekk.com/detail/Android/lightSky/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8 ...
- Android属性动画完全解析(下)
转载:http://blog.csdn.net/guolin_blog/article/details/44171115 大家好,欢迎继续回到Android属性动画完全解析.在上一篇文章当中我们学习了 ...
- Android属性动画完全解析(上),初识属性动画的基本用法
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/43536355 在手机上去实现一些动画效果算是件比较炫酷的事情,因此Android系 ...
- Android属性动画完全解析(中)
转载:http://blog.csdn.net/guolin_blog/article/details/43536355 大家好,在上一篇文章当中,我们学习了Android属性动画的基本用法,当然也是 ...
随机推荐
- Linux FACL(文件访问控制列表)
文件有三种权限 属主权限 属组权限 其他权限 现在有这样一个场景,用户 A 想把文件共享给不是同组内用户 B ,而又不想修改其他权限,这时候 FACL 就起作用了 FACL可以给文件添加一个拓展 ...
- Oracle查询表结果添加到另一张表中
转自:https://blog.csdn.net/lx870576109/article/details/78336695 把每一个知识点进行积累:Oracle数据库中将查询一张表的结果添加到另一张表 ...
- flash推流工具<转>
https://github.com/young-cowboy/young-cowboy.github.io https://www.cnblogs.com/xiaoniuzai/p/7129036. ...
- springmvc启动时报错:找不到类ContextLoaderListener:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis ...
- 关于 C++ 默认构造函数 的几个误区 转载
https://blog.csdn.net/ccrazyman/article/details/8138425
- class 方法
实例对象调用class方法时返回这个实例对象的isa指针,也就是对应的类对象: 类对象调用class方法时返回这个类对象本身. (注:如果想一直获得一个类的类对象,也就是isa指针,可以调用runti ...
- ubuntu 安装oracle客户端
from: http://webikon.com/cases/installing-oracle-sql-plus-client-on-ubuntu Installing Oracle SQL*Plu ...
- P、NP、NPC和NP-Hard相关概念的图形和解释
P.NP.NPC和NP-Hard相关概念的图形和解释 http://blog.csdn.net/huang1024rui/article/details/49154507 一.相关概念 P: 能在多项 ...
- redis集群报错:(error) MOVED 11469 192.168.163.249:7002
应该是你没有启动集群模式(即缺少了那个"-c"): redis-cli -c -h yourhost -p yourpost
- Redis进阶实践之二如何在Linux系统上安装安装Redis(转载)(2)
Redis进阶实践之二如何在Linux系统上安装安装Redis 一.引言 上一篇文章写了“如何安装VMware Pro虚拟机”和在虚拟机上安装Linux操作系统.那是第一步,有了Linux操作系统,我 ...