android 不使用xml的 Animation 简单例子
2012-10-22 16:11
393 查看
关于Animation 使用的时候,网上不断的搜索例子学习
发现都是xml 里面的
对Animation的接受有很多网友说的很清楚了
比如:http://www.moandroid.com/?p=790 他们就得很详细
我也是刚学习的
在这里贴出 不使用xml的 Animation 方法。
testDrawable.java
main.xml
发现都是xml 里面的
对Animation的接受有很多网友说的很清楚了
比如:http://www.moandroid.com/?p=790 他们就得很详细
我也是刚学习的
在这里贴出 不使用xml的 Animation 方法。
testDrawable.java
package test.drawable; import android.app.Activity; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.graphics.drawable.TransitionDrawable; import android.os.Bundle; import android.util.Log; import android.view.ViewGroup.LayoutParams; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.TranslateAnimation; import android.widget.Gallery; import android.widget.ImageView; import android.widget.LinearLayout; public class testDrawable extends Activity { LinearLayout mLinearLayout; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView spaceshipImage = (ImageView) findViewById(R.id.spaceshipImage); //Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump); //spaceshipImage.startAnimation(hyperspaceJumpAnimation); Animation animation = null; animation = new TranslateAnimation(0, 300, 0, 500); animation.setFillAfter(true);// True:图片停在动画结束位置 animation.setDuration(1000); spaceshipImage.startAnimation(animation); } }
main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/spaceshipImage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/my_image"/> </LinearLayout> 下载源码:http://download.csdn.net/detail/penglijiang/4674114
相关文章推荐
- 在 Android 上使用 XML 传输数据(附例子程序)
- APIDemo学习笔记——Android上几种简单的Animation使用方法(二)
- android中解析复杂xml(XStream简单使用)
- AndroidManifest.xml文件的作用和简单使用
- 【09.03.30】Android中使用C++程序读写Parcel的简单例子
- Android使用Fragment应用实战,简单的实习例子
- AndroidManifest.xml文件的作用和简单使用
- android 一个小例子说明handler和AlertDialog的简单使用
- 一个简单的使用XMLHttpRequest获得服务器数据的例子
- APIDemo学习笔记——Android上几种简单的Animation使用方法(三)——3D Transition
- android相机相册使用简单例子
- android发送xml信息到web服务器简单例子
- java xml api 简单使用例子
- APIDemo学习笔记——Android上几种简单的Animation使用方法(一)
- Android最简单的基于FFmpeg的例子(四)---以命令行的形式来使用ffmpeg
- Android的RadioGroup简单使用例子
- 使用Digester类的api进行xml解析的简单例子
- 一个简单的使用jdom解析xml例子
- ANDROID_MARS学习笔记_S02_008_ANIMATION第二种使用方式:xml
- Android Animation学习(三) ApiDemos解析:XML动画文件的使用