旋转平移,缩放,透明度渐变的补间动画
来源:互联网 发布:钱夫人淘宝店怎么没了 编辑:程序博客网 时间:2024/05/16 16:01
anim_alpha.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <alpha android:duration="2000" android:fillAfter="true" android:fromAlpha="1" android:repeatCount="1" android:repeatMode="reverse" android:toAlpha="0" /></set>
anim_roate.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <rotate android:duration="2000" android:fromDegrees="0" android:interpolator="@android:anim/accelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toDegrees="720" /> <rotate android:duration="2000" android:fromDegrees="360" android:interpolator="@android:anim/accelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:startOffset="2000" android:toDegrees="0" /></set>
anim_scale.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <scale android:duration="2000" android:fillAfter="true" android:fromXScale="1" android:fromYScale="1" android:interpolator="@android:anim/decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:repeatCount="1" android:repeatMode="reverse" android:toXScale="2.0" android:toYScale="2.0" /></set>
anim_translate.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="2000" android:fillAfter="true" android:fromXDelta="0" android:fromYDelta="0" android:repeatCount="1" android:repeatMode="reverse" android:toXDelta="860" android:toYDelta="0" /></set>
fragment_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/linearlayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.xwy.Bu.MainActivity$PlaceholderFragment" > <LinearLayout android:id="@+id/linearLayout2" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="旋转" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="平移" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="缩放" /> <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="透明度渐变" /> </LinearLayout> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="50px" android:src="@drawable/cat" /></LinearLayout>
MainActivity.java
package com.xwy.Bu;import android.support.v7.app.ActionBarActivity;import android.support.v7.app.ActionBar;import android.support.v4.app.Fragment;import android.app.Activity;import android.os.Bundle;import android.view.LayoutInflater;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.view.View.OnClickListener;import android.view.ViewGroup;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.Button;import android.widget.ImageView;import android.os.Build;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.fragment_main);final Animation roate = AnimationUtils.loadAnimation(this, R.anim.anim_rotate);//获取“旋转”动画资源final Animation translate=AnimationUtils.loadAnimation(this, R.anim.anim_translate);//获取“平移”动画资源final Animation scale=AnimationUtils.loadAnimation(this, R.anim.anim_scale);//获取“缩放”动画资源final Animation alpha=AnimationUtils.loadAnimation(this, R.anim.anim_alpha);//获取“透明度变化”动画资源final ImageView iv=(ImageView)findViewById(R.id.imageView1);//获取要应用动画效果的ImageViewButton button1=(Button)findViewById(R.id.button1);//获取“旋转”按钮button1.setOnClickListener(new OnClickListener() {public void onClick(View v) {iv.startAnimation(roate);//播放“旋转”动画}});Button button2=(Button)findViewById(R.id.button2);//获取“平移”按钮button2.setOnClickListener(new OnClickListener() {public void onClick(View v) {iv.startAnimation(translate);//播放“平移”动画}});Button button3=(Button)findViewById(R.id.button3);//获取“缩放”按钮button3.setOnClickListener(new OnClickListener() {public void onClick(View v) {iv.startAnimation(scale);//播放“缩放”动画}});Button button4=(Button)findViewById(R.id.button4);//获取“透明度渐变”按钮button4.setOnClickListener(new OnClickListener() {public void onClick(View v) {iv.startAnimation(alpha);//播放“透明度渐变”动画}});}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();if (id == R.id.action_settings) {return true;}return super.onOptionsItemSelected(item);}/** * A placeholder fragment containing a simple view. */public static class PlaceholderFragment extends Fragment {public PlaceholderFragment() {}@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {View rootView = inflater.inflate(R.layout.fragment_main, container,false);return rootView;}}}
0 0
- 旋转平移,缩放,透明度渐变的补间动画
- 旋转、平移、缩放和透明度渐变的补间动画
- 【Android开发】动画范例2-旋转、平移、缩放和透明度渐变的补间动画
- Android 旋转、平移、缩放和透明度渐变的补间动画
- android游戏开发5-10 补间动画 透明度渐变 旋转 缩放 平移
- Android 补间动画,具体介绍了透明度、平移,旋转,缩放4种动画效果的实现,简单易懂
- Android 补间动画(动画列表,平移,旋转,缩放,渐变,动画集合)
- 补间动画 旋转 平移 缩放 透明
- android动画(平移,旋转,缩放,透明度)
- Android动画基础:平移、缩放、旋转、透明度
- android动画的透明度渐变、旋转动画、缩放动画、评议动画
- 讲述属性动画的使用 —使用动画旋转、平移、渐变和缩放
- Android 通过Animate硬编码实现简单的平移、旋转、缩放及透明度动画过程
- 安卓的各种动画(透明度,平移,旋转,缩放)以及侦听
- 动画效果之渐变、缩放、平移、旋转<代码实现>
- 动画效果之渐变、缩放、平移、旋转<代码实现>
- Android 实现属性动画平移,旋转,缩放,渐变 《H》
- Android中属性动画1----ObjectAnimator的基本使用(平移,缩放,渐变,旋转)
- 基于HALCON的模板匹配方法总结
- struts配置spring管理
- Android Service获取当前位置(GPS+基站)
- vs2008调用opencv2.4.9的imread()函数失败解决办法
- 进程虚拟地址空间之数据分区存放
- 旋转平移,缩放,透明度渐变的补间动画
- mysql设置两个日期格式相减的方式
- rsyslog按天日志,按程序名programname分割不同日志文件
- sql语法:inner join on, left join on, right join on详细使用方法
- flume+kafka+storm调研
- HDU 2196 - Computer (树上每点最长距离 DP)
- Oracle性能优化1-总体思路和误区
- Notes for_20140710
- NGUI Font Maker 打开报错 解决方法