2013-11-05 android 图片(缩放,旋转,透明)
来源:互联网 发布:2017程序员薪资 编辑:程序博客网 时间:2024/04/30 21:42
学习不连续,很容易遗忘!一个简单的空指针提示,让我郁闷3小时,3小时啊!
不足的地方:①没有系统的去写一个demo,②API查阅也是个问题,③我还不会翻墙去看国外潮流的网站!(结合这三条,就是个HELLO)
图片的缩放,旋转,透明操作,自己去写了真的很简单!我使用的方式是XML定义,我的环境是ANDROID 4.2.2
XML中的属性定义,可以每个都试一下,我一直在做其他软件开发,对于这些属性还是不陌生。
A,缩放
定义一个XML,如下 (小放大)
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="1.0" android:fromYScale="1.0" android:toXScale="2.0" android:toYScale="2.0" android:pivotX="50%" android:pivotY="50%" android:duration="3000"/></set>定义一个XML,如下 (大缩小)
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="1.0" android:fromYScale="1.0" android:toXScale="0.5" android:toYScale="0.5" android:pivotX="50%" android:pivotY="50%" android:duration="3000"/> </set>
B,旋转
定义一个XML,如下
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"> <rotate android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="90" android:duration="3000" /></set>
C,透明
定义一个XML,如下
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:fromAlpha="1.0" android:toAlpha="0" android:duration="3000" /></set>
定义好XML之后,就是在ANDROID程序中调用这些XML,来达到我们想要的效果了,效果前的原图如下(图片为网上下载,如有不妥,请告之):
代码调用如下(自己写来学习的,当中的各种命名不规范),对于我这超级新手都能理解,我想注释应该不会有:
package com.example.tween_ys;import android.os.Bundle;import android.app.Activity;import android.graphics.Matrix;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.Button;import android.widget.ImageView;import android.widget.Toast;public class MainActivity extends Activity implements OnClickListener {public Animation animation;public ImageView image;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button button4 = (Button) this.findViewById(R.id.t);Button button3 = (Button) this.findViewById(R.id.xz);Button button2 = (Button) this.findViewById(R.id.xd);Button button1 = (Button) this.findViewById(R.id.dx);image = (ImageView) findViewById(R.id.img); button4.setOnClickListener(this);button3.setOnClickListener(this);button2.setOnClickListener(this);button1.setOnClickListener(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.t:Toast.makeText(MainActivity.this.getApplicationContext(), "透明", 0).show();animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.anima);image.startAnimation(animation);break;case R.id.dx:Toast.makeText(MainActivity.this.getApplicationContext(), "大缩小", 0).show();animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.sf);image.startAnimation(animation); break;case R.id.xd:Toast.makeText(MainActivity.this.getApplicationContext(), "小放大", 0).show();animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.xd);image.startAnimation(animation);break;case R.id.xz:Toast.makeText(MainActivity.this.getApplicationContext(), "旋转", 0).show();animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.xz);image.startAnimation(animation);break;default:break;}}}
程序运行之后的效果:
A,缩放
B,选择
C,透明
- 2013-11-05 android 图片(缩放,旋转,透明)
- android 中四种补间动画(透明,平移,缩放,旋转)
- Android 图片缩放与旋转
- android图片缩放与旋转
- Android 图片旋转 缩放 平移
- Android图片查看器(图片可移动、缩放、旋转)
- SWT图片处理(大小缩放,透明,置灰,旋转,反色)
- php学习笔记(十六)图片的处理缩放、旋转、透明、锐化、翻转、裁剪
- D3D 中LPD3DXSPRITE(点精灵)对图片进行缩放旋转透明处理
- SWT图片处理(大小缩放,透明,置灰,旋转,反色)
- SWT图片处理(大小缩放,透明,置灰,旋转,反色)
- Android缩放图片和旋转图片示例
- Android组件 图片的缩放以旋转(Matrix)
- Android图片预览功能(可旋转、缩放、左右切换)
- Android-补间动画基本使用(位移、缩放、旋转、透明)
- Android view的移动,旋转,缩放,透明等效果
- 在android平台缩放和旋转图片
- Android 图片旋转,缩放,切割,叠加处理
- SQL 分页语句
- java中的多线程
- linux默认端口范围是多少?
- windows中安装openvpn虚拟网卡
- android broadcast
- 2013-11-05 android 图片(缩放,旋转,透明)
- 新的开始
- SWFObject参数
- 在ORACLE中修改字段的长度
- 关于select函数中struct timeval问题
- wpf中添加右键菜单,后台
- Oracle学习—总结
- 学习JGroups总结
- jQuery.ajax(url,[settings])