四月份来了,我也要加紧学习了,下面的动画类型

android动画编

看看实现的代码package com.smart;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.view.animation.TranslateAnimation;import android.widget.AdapterView;import android.widget.ArrayAdapter;import android.widget.Spinner;public class Main extends Activity implements AdapterView.OnItemSelectedListener{private static final String[] INTERPOLATORS={"加快", "减速", "加快/减速", "预料","过冲", "预计/过冲", "弹跳" };//类型    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        Spinner s=(Spinner)findViewById(R.id.spinner);        ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,INTERPOLATORS);        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);        s.setAdapter(adapter);//得到控件        s.setOnItemSelectedListener(this);                    }    @Overridepublic void onItemSelected(AdapterView<?> parent, View v, int position,long id) {final View target=(View)findViewById(R.id.target);final View targetParent=(View)target.getParent();//得到动画Animation animation= new TranslateAnimation(0.0f, targetParent.getWidth()- target.getWidth()- targetParent.getPaddingLeft()- targetParent.getPaddingRight(), 0.0f, 0.0f);animation.setDuration(1000);animation.setStartOffset(300);animation.setRepeatMode(Animation.RESTART);animation.setRepeatCount(Animation.INFINITE);//选择动来类型switch (position) {case 0:animation.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_interpolator));break;case 1:animation.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.decelerate_interpolator));break;case 2:animation.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator));break;case 3:animation.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.anticipate_interpolator));break;case 4:animation.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.overshoot_interpolator));break;case 5:animation.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.anticipate_overshoot_interpolator));break;case 6:animation.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.bounce_interpolator));break;}target.startAnimation(animation);}@Overridepublic void onNothingSelected(AdapterView<?> arg0) {}}XML代码<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:padding="10dip"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:clipToPadding="false"    ><TextView  android:id="@+id/target"    android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:textSize="16sp"    android:text="朋友,看看我,跑得多快!"    />        <TextView      android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:textSize="15dip"    android:layout_marginBottom="5dip"    android:text="请选择动画类型"    />        <Spinner  android:id="@+id/spinner"    android:layout_width="fill_parent"     android:layout_height="wrap_content"     /></LinearLayout>

更多相关文章

  1. Android 自定义Gif动画
  2. Android Design: 九种常见Activity及代码解析之"Login Activity"
  3. [CSDN]Android应用程序进程启动过程的源代码分析
  4. Android 9.0 开关机动画流程分析
  5. Android开源项目源代码分享
  6. 如何用代码区分android TV和手机? 适配Android TV ?

随机推荐

  1. [Android]在Avtivity中注册监听器
  2. android软键盘的隐藏
  3. Android(安卓)通过Http访问Web端的Servle
  4. Android(安卓)setBrightness value
  5. Android(安卓)之 ImageSwitch图片转换器
  6. android获取屏幕分辨率实现
  7. Android(安卓)自动更新代码
  8. Android放大镜实现的两种方式
  9. start of WindowManagerService
  10. android系统提供的几种颜色Color