程序实现缩放
来源:互联网 发布:php 魔术方法 编辑:程序博客网 时间:2024/06/07 20:10
准备一张名为picture的图片。
在main.xml中:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical"
android:gravity="center_horizontal">
<ImageView
android:id="@+id/mlyw"
android:layout_marginTop="8dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/picture"/>
<Button
android:id="@+id/but"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#3399ff"
android:textColor="#ffffff"
android:text="开始缩放"/>
</LinearLayout>
在MyAnimationDemo.java中:
package com.li.animation;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.support.v4.app.NavUtils;
public class MyAnimationDemo extends Activity {
private ImageView mlyw = null;
private Button but = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.main);
this.mlyw = (ImageView)super.findViewById(R.id.mlyw);
this.but = (Button)super.findViewById(R.id.but);
this.but.setOnClickListener(new OnClickListenerImpl());
}
private class OnClickListenerImpl implements OnClickListener{
public void onClick(View v) {
AnimationSet set = new AnimationSet(true);
ScaleAnimation scale = new ScaleAnimation(
1,0.0f, 1,0.0f ,
Animation.RELATIVE_TO_SELF,0.5f,
Animation.RELATIVE_TO_SELF,0.5f); //(0.5f,0.5f)中心缩放
scale.setDuration(5000); //5秒完成
set.addAnimation(scale); //增加动画
MyAnimationDemo.this.mlyw.startAnimation(set); //启动动画
}
}
}
- 程序实现缩放
- 程序实现移动+缩放
- 通过pyrUp和pyrDown实现图像缩放的简单程序
- Java 实现的简单图片缩放小程序
- ifanr:微信小程序中实现手势缩放图片
- 一个简单的实现图片缩放的程序
- matlab图像缩放程序
- 图像缩放程序
- 微信小程序 图片缩放
- SWFLoader实现任意缩放
- SWFLoader实现任意缩放
- css3实现浏览器缩放
- MFC缩放实现
- ava 图片缩放 实现
- javascript 实现图片缩放
- opencv实现图像缩放
- OpenCV实现图像缩放
- 配置文件实现缩放
- Hibernate学习
- Word Reversal
- There is no getter for property named 'xxxx' in 'class java.lang.Integer
- 冒泡算法排序数组
- 树的递归遍历和非递归遍历(前序和后序)
- 程序实现缩放
- dbcp_20130911
- 计算几何模板(转自Archibaldyangfan)
- SQLiteOpenHelper类与自动升级数据库
- msyql中子查询IN,EXISTS,ANY,ALL,UNION介绍
- C/C++中的联合体union及CPU大小端判定
- 程序实现移动
- 统计字符串中每个字符出现的次数
- string在c++中的各种用法分析