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 ...
随机推荐
- ios 数据库存储json数据
NSData *data = [NSJSONSerialization dataWithJSONObject:info.bdata options:NSJSONWritingPrettyPrinted ...
- ceil 模块
# 有时需要得到一个最小的整数,而这个数只能比自己大或相等,不能小于自己 #如: 2.1 我们需要得到的最小整数为3,即使后一位只有很小的一部分,一般用于分页 from math import cei ...
- SQL基本语句汇总
语句:CREATE TABLE 作用:创建表格 格式:CREATE TABLE tableName (columnName1 columnDataType1, columnName2 columnDa ...
- web程序的路径笔记
"/"与”\“区别:”/“是unix系统区分文件层级的标志,因为当前web应用程序在服务器端大都使用基于unix系统开发的操作系统,所以web程序包括浏览器里url都遵以”/“来区 ...
- jquery修改Switchery复选框的状态
script //选择框 var mySwitch; /* * 初始化Switchery * * classNmae class名 */ function initSwitchery(classNam ...
- ButterKnife--View注入框架的使用
作为一名Android开发,是不是经常厌烦了大量的findViewById以及setOnClickListener代码,而ButterKnife是一个专注于Android系统的View注入框架,让你从 ...
- HTTP 错误 500.21 - Internal Server Error 处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”
HTTP 错误 500.21 - Internal Server Error 处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipe ...
- Github上传代码菜鸟超详细教程
最近需要将课设代码上传到Github上,之前只是用来fork别人的代码. 这篇文章写得是windows下的使用方法. 第一步:创建Github新账户 第二步:新建仓库 第三部:填写名称,简介(可选 ...
- .NET程序反汇编JustDecompile 开源
JustDecompile是Telerik公司推出一个免费的.net反编译工具,支持插件,与Visual Studio 集成,能够创建Visual Studio project文件.JustDecom ...
- TCP/UDP简易通信框架源码,支持轻松管理多个TCP服务端(客户端)、UDP客户端
目录 说明 TCP/UDP通信主要结构 管理多个Socket的解决方案 框架中TCP部分的使用 框架中UDP部分的使用 框架源码结构 补充说明 源码地址 说明 之前有好几篇博客在讲TCP/UDP通信方 ...