android图片透明度跟缩放大小动画事件
概序 : 动画事件写在xml中,然后用AnimationUtils去加载动画事件,再监听动画结束事件,隐藏imageview。
1. player_double_click_animation.xml 动画文件
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<alpha
android:duration="800"
android:fromAlpha="0.1"
android:toAlpha="1.0"/> <scale
android:duration="800"
android:fillAfter="false"
android:fromXScale="0.2"
android:fromYScale="0.2"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0"/>
</set>
alpha参数说明:
android:fromAlpha="1.0" //这是表示动画一开始是完全不透明
android:toAlpha="0.0" //这是表示动画结果时是完全透明
android:duration="500" //这是动画的时间
scale参数说明:
float fromX 动画起始时 X坐标上的伸缩尺寸
float toX 动画结束时 X坐标上的伸缩尺寸
float fromY 动画起始时Y坐标上的伸缩尺寸
float toY 动画结束时Y坐标上的伸缩尺寸
int pivotXType 动画在X轴相对于物件位置类型
float pivotXValue 动画相对于物件的X坐标的开始位置
int pivotYType 动画在Y轴相对于物件位置类型
float pivotYValue 动画相对于物件的Y坐标的开始位置
2.布局文件test_aniamtion.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:id="@+id/click"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击我" /> <ImageView
android:id="@+id/like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/icon_video_double_click"
android:visibility="gone" /> </LinearLayout>
3.MainActivity.java
public class MainActivity extends Activity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_aniamtion);
findViewById(R.id.click).setOnClickListener(listener);
imageView=(ImageView) findViewById(R.id.like);
}
private OnClickListener listener=new OnClickListener() {
@Override
public void onClick(View v) {
imageView.setVisibility(View.VISIBLE);
//加载动画
Animation animation=AnimationUtils.loadAnimation(MainActivity.this,R.anim.player_double_click_animation);
imageView.startAnimation(animation);//开始动画
animation.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {//动画结束
imageView.setVisibility(View.GONE);
}
});
}
};
}
效果图如下:
android图片透明度跟缩放大小动画事件的更多相关文章
- android 图片的平移,缩放和旋转
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...
- 01-实现图片按钮的缩放、动画效果(block的初步应用)
#import "ViewController.h" #define kDelta 60 @interface ViewController () @end @implementa ...
- iOS Swift 实现图片点击缩放回弹动画
效果就是下面这个样子: 思路借鉴的是MZTimerLabel,有想过做一个自定义的ImageView,但那样的话之前view用必须要改代码,索性就按照MZTimerLabel这个方式实现,简单易用,从 ...
- 用 jQuery实现图片等比例缩放大小
原文:http://www.open-open.com/code/view/1420975773093 <script type="text/javascript"> ...
- 微信小程序实现图片双滑缩放大小
在做小程序开发的过程中,后端传来一张图片地图,需要实现双手指滑动,使图片缩放,最终得出了一下代码: js : Page({ data: { touch: { distance: , scale: , ...
- android图片等比例缩放 填充屏幕
在ImageView的t同事设置两个属性 android:adjustViewBounds="true"android:scaleType="fitXY"
- android图片处理方法
Java代码 //压缩图片大小 public static Bitmap compressImage(Bitmap image) { ByteArrayOutputStream baos = new ...
- android图片处理方法(不断收集中)
//压缩图片大小 public static Bitmap compressImage(Bitmap image) { ByteArrayOutputStream baos = new ByteArr ...
- Android 图片处理方法
//压缩图片大小 public static Bitmap compressImage(Bitmap image) { ByteArrayOutputStream baos = new ByteArr ...
随机推荐
- javaweb学习记录(1)
Java基础学习笔录 1.运行java程序,出现bad version number in.class file 编译器()的版本号高于运行环境(jre)的版本号,可以降低编译器版本号,也可以通过提升 ...
- sort命令
1.默认情况下,sort命令,以字母序进行文本排序sort word.txt2.如果想对数字进行排序,可以使用-n参数sort num.txt -n3指定列排序下面是对passwd文件,以冒号(:)进 ...
- 新入门node.js必须要知道的概念
一.对于一个刚入门node.js的朋友来说,一定要了解一些基础概念: 今年我正式进入社会后,发现自己所知道的IT方面的知识,真的只是牛毛,原来人外有人,山外有山,还需要继续努力.下面是一些我的自学习心 ...
- STM32之ADC+步骤小技巧(英文)
神通广大的各位互联网的网友们.大家早上中午晚上好好好.今早起来很准时的收到了两条10086的扣月租的信息.心痛不已.怀着这心情.又开始了STM32的研究.早上做了计算机控制的PID实验,又让我想起了飞 ...
- 字符串转换为数字---使用java7的装箱功能
以前转换只知道使用Xxx.prasexxx方法,原来,还可以直接装箱自动转换. //String类型字符串 String intStr = "123"; int str2int1 ...
- angurlarjs学习笔记
AngularJS 根作用域($rootScope) 所有的应用都有一个 $rootScope,它可以作用在 ng-app 指令包含的所有 HTML 元素中 $rootScope 可作用于整个应用中. ...
- eclipse 下找不到或无法加载主类的解决办法
有时候 Eclipse 会发神经,好端端的 project 就这么编译不了了,连 Hello World 都会报“找不到或无法加载主类”的错误,我已经遇到好几次了,以前是懒得深究就直接重建projec ...
- 一张图解释SQL Server集群、镜像、复制、日志传送
一张图解释SQL Server集群.镜像.复制.日志传送 本文版权归作者所有,未经作者同意不得转载.
- Visual Studio “14” CTP 4
微软发布于10月6日发布了Visual Studio "14"CTP 4,本次发布的更新主要包括:ASP.NET vNext runtime和一些工具的优化(ASP.NET vNe ...
- Creating a Clean, Minimal-Footprint ASP.NET WebAPI Project with VS 2012 and ASP.NET MVC 4
Creating a Clean, Minimal-Footprint ASP.NET WebAPI Project with VS 2012 and ASP.NET MVC 4 Building O ...