GVKun编程网logo

scipy.ndimage.interpolation.rotate之后旋转的图像坐标?(scipy rotation)

2

对于scipy.ndimage.interpolation.rotate之后旋转的图像坐标?感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍scipyrotation,并为您提供关于androi

对于scipy.ndimage.interpolation.rotate之后旋转的图像坐标?感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍scipy rotation,并为您提供关于android – applyTransformation用interpolatedTime == 1调用两次、android – 使用ACTION_IMAGE_CAPTURE拍摄的图像在某些Gingerbread设备上的ExifInterface.TAG_ORIENTATION返回1、Android 中使用 Animation 实现控件的动画效果以及 Interpolator 和 AnimationListener 的使用、android.animation.TimeInterpolator的实例源码的有用信息。

本文目录一览:

scipy.ndimage.interpolation.rotate之后旋转的图像坐标?(scipy rotation)

scipy.ndimage.interpolation.rotate之后旋转的图像坐标?(scipy rotation)

我有一个numpy数组,用于从FITS文件读取的图像。我使用旋转了N度scipy.ndimage.interpolation.rotate。然后,我想弄清楚原始非旋转帧中某个点(x,y)在旋转图像中最终的位置-即,旋转帧坐标(x’,y’)是什么?

这应该是一个非常简单的旋转矩阵问题,但是如果我执行通常的基于数学或编程的旋转方程,则新的(x’,y’)不会以它们原来的位置结束。我怀疑这也与需要转换矩阵有关,因为scipy旋转函数基于原点(0,0)而不是图像阵列的实际中心。

有人可以告诉我如何获得旋转的镜架(x’,y’)吗?例如,您可以使用

from scipy import misc
from scipy.ndimage import rotate
data_orig = misc.face()
data_rot = rotate(data_orig,66) # data array
x0,y0 = 580,300 # left eye; (xrot,yrot) should point there

android – applyTransformation用interpolatedTime == 1调用两次

android – applyTransformation用interpolatedTime == 1调用两次

我有一个ListView,其项目需要与动画折叠,然后删除.我使用动画来折叠项目,在完成折叠后,我从ListView中删除项目(通过从数据列表中删除它并调用notifyDataSetChanged).要检测动画是否完成,请检查applyTransformation方法中的interpolatedTime == 1.0.问题是applyTransformation被`interpolatedTime’== 1调用两次,所以我不能真正依赖它(否则我可以删除两个项而不是一个).为什么会这样?这是我的一些代码:

public static void collapseAndDelete(final View v, final ArrayList<AlarmClock> alarmClockArrayList,
                                     final AlarmsArrayAdapter adapter, final int position) {
    final int initialHeight = v.getMeasuredHeight();
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {

            if (interpolatedTime == 1) {
                alarmClockArrayList.remove(position);
                adapter.notifyDataSetChanged();
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
                v.setAlpha(1.0f - interpolatedTime);
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };
    a.setDuration(400);
    v.startAnimation(a);
}

解决方法:

实现动画侦听器以捕获最终回调

r.setAnimationListener(new OAnimationListener(this));

班级的例子:

public class OAnimationListener implements AnimationListener{

    private MyView vv;


    public OAnimationListener(MyView vv) {
        // Todo Auto-generated constructor stub
        this.vv = vv;
    }

    @Override
    public void onAnimationStart(Animation animation) {
        // Todo Auto-generated method stub

    }

    @Override
    public void onAnimationRepeat(Animation animation) {
        // Todo Auto-generated method stub

    }

    @Override
    public void onAnimationEnd(Animation animation) {
        if (vv != null)
            vv.stopAnim(2); //or any wanted callback

    }
}

别忘了设置这个:

r.setRepeatCount(0);

                r.setFillAfter(true);

android – 使用ACTION_IMAGE_CAPTURE拍摄的图像在某些Gingerbread设备上的ExifInterface.TAG_ORIENTATION返回1

android – 使用ACTION_IMAGE_CAPTURE拍摄的图像在某些Gingerbread设备上的ExifInterface.TAG_ORIENTATION返回1

使用ACTION_IMAGE_CAPTURE活动时,我遇到了方向问题.我已经使用了TAG_ORIENTATION,因此我会相应地旋转图片.但现在我们发现在一些较新的设备上这不起作用.事实上,它为所有方向返回1.

这是我们观察到的设备列表;

>三星Infuse 4G(2.3.3)
>三星galaxy SII X(2.3.5)
> Sony Xperia Arc(2.3.3)

有趣的是,一旦这个图像是图库它正确显示,如果我选择它,TAG_ORIENTATION就会正确填充.因此,操作系统以某种方式正确填充此信息,但不在ActivityResult上填充.

确定方向的最可靠方法是什么?有人在另一个问题上建议比较高度和宽度但是在获得这些时,它们会根据方向正确切换(另一个谜)

编辑:这似乎可以连接到另一个错误,其中操作系统复制在库中拍摄的图像(它只应该将图像保存在我们指定的URL中),事实是图库中的这个图像具有ORIENTATION信息而指定位置的那个没有.

这是错误; http://code.google.com/p/android/issues/detail?id=19268

编辑2:我已经向Android提交了一个新的错误.我很确定这是与上述错误相关的操作系统错误.
http://code.google.com/p/android/issues/detail?id=22822

解决方法:

好吧,看起来这个Android的bug将暂时无法修复.虽然我找到了一种方法来实现Exifinformation,以便两个设备(具有正确的Exif标签,以及不正确的exif标签一起工作).

所以问题出在一些(较新的)设备上,有一个错误,使得拍摄的照片保存在您的app文件夹中而没有正确的exif标签,而正确旋转的图像保存在android默认文件夹中(即使它不应该). .

现在我做的是,我记录我从我的应用程序启动相机应用程序的时间.在活动结果上,我查询媒体提供商,看看在我保存的这个时间戳之后是否保存了任何图片.这意味着,很可能操作系统将正确旋转的图片保存在默认文件夹中,当然在媒体商店中放入一个条目,我们可以使用此行中的轮换信息.现在为了确保我们正在查看正确的图像,我将此文件的大小与我有权访问的文件(保存在我自己的应用程序文件夹中)进行比较;

    int rotation =-1;
    long fileSize = new File(filePath).length();

    Cursor mediaCursor = content.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] {MediaStore.Images.ImageColumns.ORIENTATION, MediaStore.MediaColumns.SIZE }, MediaStore.MediaColumns.DATE_ADDED + ">=?", new String[]{String.valueOf(captureTime/1000 - 1)}, MediaStore.MediaColumns.DATE_ADDED + " desc");

    if (mediaCursor != null && captureTime != 0 && mediaCursor.getCount() !=0 ) {
        while(mediaCursor.movetoNext()){
            long size = mediaCursor.getLong(1);
            //Extra check to make sure that we are getting the orientation from the proper file
            if(size == fileSize){
                rotation = mediaCursor.getInt(0);
                break;
            }
        }
    }

现在,如果此时的旋转仍为-1,那么这意味着这是具有正确旋转信息的手机之一.此时,我们可以在返回到onActivityResult的文件上使用常规exif方向

    else if(rotation == -1){
        rotation = getExifOrientationAttribute(filePath);
    }

您可以在这个问题Camera orientation issue in Android中轻松找到如何找到exif方向,如答案

另请注意,只有在Api等级5之后才支持ExifInterface.因此,如果您想在2.0之前支持手机,那么您可以使用我找到的这个方便的库,用于Java提供的Drew Noakes; http://www.drewnoakes.com/code/exif/

祝你的形象旋转好运!

编辑:因为有人问,我使用的意图和我的开始是这样的

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//mediaFile is where the image will be saved
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mediaFile));
startActivityForResult(intent, 1);

Android 中使用 Animation 实现控件的动画效果以及 Interpolator 和 AnimationListener 的使用

Android 中使用 Animation 实现控件的动画效果以及 Interpolator 和 AnimationListener 的使用

Android 中使用 Animation 实现控件的动画效果以及 Interpolator 和 AnimationListener 的使用

http://www.itzhai.com/android-animation-used-to-achieve-control-of-animation-effects-and-use-of-interpolator-and-animationlistener.html

Animation 的 4 个基本动画效果

What is Animation?

public abstract class
Animation
extends Object
implements Cloneable

Abstraction for an Animation that can be applied to Views, Surfaces, or other objects.

1、AlphaAnimation:淡入淡出效果
public class
AlphaAnimation
extends Animation

An animation that controls the alpha level of an object. Useful for fading things in and out. This animation ends up changing the alpha property of aTransformation

Public Constructors
AlphaAnimation(Context context, AttributeSet attrs)
Constructor used when an AlphaAnimation is loaded from a resource.
AlphaAnimation(float fromAlpha, float toAlpha)
Constructor to use when building an AlphaAnimation from code
public class
AnimationSet
extends Animation

Represents a group of Animations that should be played together. The transformation of each individual animation are composed together into a single transform. If AnimationSet sets any properties that its children also set (for example, duration or fillBefore), the values of AnimationSet override the child values.


在代码中实现动画效果的方法:

ImageView imageView = (ImageView) findViewById(R.id.imageView1);
AnimationSet animationSet = new AnimationSet(true);
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
alphaAnimation.setDuration(1000);
alphaAnimation.setStartOffset(10000);
animationSet.addAnimation(alphaAnimation);
//animationSet.setStartOffset(10000);
animationSet.setFillBefore(false);
animationSet.setFillAfter(true);
imageView.startAnimation(animationSet);


在 XML 文件中实现动画效果的方法:

① 在 res 目录下创建一个 anim 文件夹,在里面添加一个 alpha.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_interpolator"
	android:fillAfter="true"
	android:fillBefore="false">
	<alpha
		android:fromAlpha="1.0"
		android:toAlpha="0.0"
		android:startOffset="1000"
		android:duration="1000" />

</set>

② 在 Activity 中使用 AnimationUtils 获取 Animation 并进行设置:

Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha);
imageView.startAnimation(animation);
2、ScaleAnimation:缩放效果
public class
ScaleAnimation
extends Animation

An animation that controls the scale of an object. You can specify the point to use for the center of scaling.

Public Constructors
ScaleAnimation(Context context, AttributeSet attrs)
Constructor used when a ScaleAnimation is loaded from a resource.
ScaleAnimation(float fromX, float toX, float fromY, float toY)
Constructor to use when building a ScaleAnimation from code
ScaleAnimation(float fromX, float toX, float fromY, float toY, float pivotX, float pivotY)
Constructor to use when building a ScaleAnimation from code
ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
Constructor to use when building a ScaleAnimation from code


在代码中实现动画效果:

ImageView imageView = (ImageView) findViewById(R.id.imageView1);
AnimationSet animationSet = new AnimationSet(true);
ScaleAnimation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
		Animation.RELATIVE_TO_SELF, 1f,
		Animation.RELATIVE_TO_SELF, 1f);
animationSet.addAnimation(scaleAnimation);
animationSet.setDuration(1000);
imageView.startAnimation(animationSet);


在 XML 文件中实现动画效果的方法:

① 在 res 的 anim 文件夹下,创建一个 scale.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_interpolator">

	<scale android:fromXScale="1.0"
		android:toXScale="0.0"
		android:fromYScale="1.0"
		android:toYScale="0.0"
		android:pivotX="50%"
		android:pivotY="50%"
		android:duration="2000" />

</set>

② 在 Activity 中使用 AnimationUtils 获取 Animation 并进行设置:

Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.scale);
imageView.startAnimation(animation);
3、Rotate:旋转效果
public class
RotateAnimation
extends Animation

An animation that controls the rotation of an object. This rotation takes place int the X-Y plane. You can specify the point to use for the center of the rotation, where (0,0) is the top left point. If not specified, (0,0) is the default rotation point.

Public Constructors
RotateAnimation(Context context, AttributeSet attrs)
Constructor used when a RotateAnimation is loaded from a resource.
RotateAnimation(float fromDegrees, float toDegrees)
Constructor to use when building a RotateAnimation from code.
RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
Constructor to use when building a RotateAnimation from code
RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
Constructor to use when building a RotateAnimation from code


在代码中实现动画效果:

ImageView imageView = (ImageView) findViewById(R.id.imageView1);
AnimationSet animationSet = new AnimationSet(true);
RotateAnimation rotateAnimation = new RotateAnimation(0, 360,
		Animation.RELATIVE_TO_PARENT, 0.5f,
		Animation.RELATIVE_TO_PARENT, 0.5f);
rotateAnimation.setDuration(1000);
animationSet.addAnimation(rotateAnimation);
imageView.startAnimation(animationSet);


在 XML 文件中实现动画效果的方法:

① 在 res 的 anim 文件夹下,创建一个 rotate.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_interpolator">

	<rotate android:fromDegrees="0"
		android:toDegrees="+360"
		android:pivotX="50%"
		android:pivotY="50%"
		android:duration="1000" />
</set>

② 在 Activity 中使用 AnimationUtils 获取 Animation 并进行设置:

Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.rotate);
imageView.startAnimation(animation);
4、 Translate:移动效果
public class
TranslateAnimation
extends Animation

An animation that controls the position of an object.

Public Constructors
TranslateAnimation(Context context, AttributeSet attrs)
Constructor used when a TranslateAnimation is loaded from a resource.
TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
Constructor to use when building a TranslateAnimation from code
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)
Constructor to use when building a TranslateAnimation from code


在代码中实现动画效果:

ImageView imageView = (ImageView) findViewById(R.id.imageView1);
AnimationSet animationSet = new AnimationSet(true);
TranslateAnimation translateAnimation = new TranslateAnimation(
		Animation.RELATIVE_TO_SELF, 0f,
		Animation.RELATIVE_TO_SELF, 1.0f,
		Animation.RELATIVE_TO_SELF, 0f,
		Animation.RELATIVE_TO_SELF, 1.0f);
translateAnimation.setDuration(1000);
animationSet.addAnimation(translateAnimation);
imageView.startAnimation(animationSet);


在 XML 文件中实现动画效果的方法:

① 在 res 的 anim 文件夹下,创建一个 translate.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_interpolator">

	<translate
		android:fromXDelta="0%p"
		android:toXDelta="100%p"
		android:fromYDelta="0%p"
		android:toYDelta="100%p"
		android:duration="1000" />

</set>

其中 100% p 表示相对于父空间的位置

② 在 Activity 中使用 AnimationUtils 获取 Animation 并进行设置:

Animation animation = (Animation) AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate);
imageView.startAnimation(animation);
也可以使用 AnimationSet 为一个控件添加多个动画,或者在 xml 文件中添加多个动画标签,以下分别使用代码和 XML 文件实现相同的效果:
代码中实现:
AnimationSet animationSet = new AnimationSet(false);
AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
ScaleAnimation scale = new ScaleAnimation(1, 0.5f, 1, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
animationSet.addAnimation(alpha);
animationSet.addAnimation(scale);
animationSet.setDuration(2000);
animationSet.setStartOffset(1000);
animationSet.setFillAfter(true);
imageView.startAnimation(animationSet);
XML 实现:

alpha.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_interpolator"
	android:shareInterpolator="true"
	android:fillAfter="true">

	<alpha
		android:fromAlpha="1.0"
		android:toAlpha="0.0"
		android:startOffset="1000"
		android:fillAfter="true"
		android:duration="2000" />

	<scale android:fromXScale="1.0"
		android:toXScale="0.5"
		android:fromYScale="1.0"
		android:toYScale="0.5"
		android:pivotX="50%"
		android:pivotY="50%"
		android:startOffset="1000"
		android:duration="2000" />
</set>

Activity 中的代码:

Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha);
imageView.startAnimation(animation);
Interpolator 的使用


什么是 Interpolator

public class
Interpolator
extends Object
Interpolator 定义了动画变化的速率或规律,其具体的实现可以使用以下子类:


AccelerateDecelerateInterpolator:

public class
AccelerateDecelerateInterpolator
extends Object
implements Interpolator

An interpolator where the rate of change starts and ends slowly but accelerates through the middle.


AccelerateInterpolater:

public class
AccelerateInterpolator
extends Object
implements Interpolator

An interpolator where the rate of change starts out slowly and and then accelerates.


CycleInterpolator:

public class
CycleInterpolator
extends Object
implements Interpolator

Repeats the animation for a specified number of cycles. The rate of change follows a sinusoidal pattern.


DecelerateInterpolator:

public class
DecelerateInterpolator
extends Object
implements Interpolator

An interpolator where the rate of change starts out quickly and and then decelerates.


LinearInterpolator:

public class
LinearInterpolator
extends Object
implements Interpolator

An interpolator where the rate of change is constant.

这些 Interpolator 可以在代码或 XML 文件中定义:


XML 文件定义在 set 标签里或每个动画标签

set 标签中定义:

<set xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_interpolator"
	android:shareInterpolator="true"
	android:fillAfter="true">

每个动画标签中定义:

<set xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_interpolator"
	android:shareInterpolator="false"
	android:fillAfter="true">
	<alpha
		android:interpolator="@android:anim/accelerate_interpolator"
		android:fromAlpha="1.0"
		android:toAlpha="0.0"
		android:startOffset="1000"
		android:fillAfter="true"
		android:duration="2000" />

	<scale
		android:interpolator="@android:anim/accelerate_decelerate_interpolator"
		android:fromXScale="1.0"
		android:toXScale="0.5"
		android:fromYScale="1.0"
		android:toYScale="0.5"
		android:pivotX="50%"
		android:pivotY="50%"
		android:startOffset="1000"
		android:duration="2000" />
</set>


在代码中设置:

AnimationSet animationSet = new AnimationSet(true);
animationSet.setInterpolator(new AccelerateInterpolator());

或者分别为每个动画设置:

AnimationSet animationSet = new AnimationSet(false);
AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
alpha.setInterpolator(new AccelerateInterpolator());
ScaleAnimation scale = new ScaleAnimation(1, 0.5f, 1, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
scale.setInterpolator(new AccelerateDecelerateInterpolator());
Frame-By-Frame Animations 的使用

① 准备 4 张图片 run1.png,run2.png,run3.png,run4.png 分别放到 res 的三个 drawable 文件夹中
② 在 res 的 drawable-ldpi 目录下创建一个 anim_run.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
	android:oneshot="false">
	<item android:drawable="@drawable/run1" android:duration="100" />
	<item android:drawable="@drawable/run2" android:duration="100" />
	<item android:drawable="@drawable/run3" android:duration="100" />
	<item android:drawable="@drawable/run4" android:duration="100" />
</animation-list>

③ 在 Activity 中使用 xml 文件设置 ImageView 控件 imageView 的背景源,并获取 AnimationDrawable 进行显示动画:

imageView.setBackgroundResource(R.drawable.anim_run);
AnimationDrawable animationDrawable = (AnimationDrawable)imageView.getBackground();
animationDrawable.start();
使用 LayoutAnimationController 设置 ListView 的动画


什么是 LayoutAnimationController?

public class
LayoutAnimationController
extends Object

A layout animation controller is used to animated a layout''s, or a view group''s, children. Each child uses the same animation but for every one of them, the animation starts at a different time. A layout animation controller is used by ViewGroup to compute the delay by which each child''s animation start must be offset. The delay is computed by using characteristics of each child, like its index in the view group. This standard implementation computes the delay by multiplying a fixed amount of miliseconds by the index of the child in its parent view group. Subclasses are supposed to override getDelayForView(android.view.View) to implement a different way of computing the delay. For instance, aGridLayoutAnimationController will compute the delay based on the column and row indices of the child in its parent view group. Information used to compute the animation delay of each child are stored in an instance of LayoutAnimationController.AnimationParameters, itself stored in theViewGroup.LayoutParams of the view.


在使用 LayoutAnimationController 控制 ListView 控件的样式效果的方法:

① 在 res 的 anim 文件夹中创建一个 list_anim.xml 文件用于控制 ListView 控件的动画:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
	android:interpolator="@android:anim/accelerate_interpolator"
	android:shareInterpolator="true">

	<scale android:fromXScale="0.0"
		android:toXScale="1.0"
		android:fromYScale="0.0"
		android:toYScale="1.0"
		android:pivotX="50%"
		android:pivotY="50%"
		android:duration="1000" />
</set>

② 创建一个布局文件 item.xml 用于设置 ListView 的 item 的样式:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="fill_parent" android:layout_height="fill_parent"
	android:orientation="horizontal" android:paddingLeft="10dip"
	android:paddingRight="10dip" android:paddingTop="1dip"
	android:paddingBottom="1dip">
	<TextView android:id="@+id/user_name" android:layout_width="180dip"
		android:layout_height="30dip"
		android:textSize="10pt"
		android:singleLine="true" />
	<TextView android:id="@+id/user_id" android:layout_width="fill_parent"
		android:layout_height="fill_parent"
		android:textSize="10pt"
		android:singleLine="true"/>
</LinearLayout>

③ 在主 Activity 的布局文件 main.xml 中添加一个 ListView

<ListView
		android:id="@id/android:list"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:scrollbars="vertical"
		android:layoutAnimation="@anim/anim_layout"
		/>

④ 创建一个 MainActivity 继承 ListActivity,并在 onCreate 方法中添加如下代码:

ListView listView = getListView();

List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
HashMap<String, String> hm1 = new HashMap<String, String>();
hm1.put("user_name", "arthinking");
hm1.put("user_id", "001");
HashMap<String, String> hm2 = new HashMap<String, String>();
hm2.put("user_name", "Jason");
hm2.put("user_id", "002");
list.add(hm1);
list.add(hm2);

SimpleAdapter simpleAdapter = new SimpleAdapter(this, list,
		R.layout.item, new String[] { "user_name", "user_id" },
		new int[] { R.id.user_name, R.id.user_id });
listView.setAdapter(simpleAdapter);

//通过Animation获取LayoutAnimationController对ListView进行设置
Animation animation = (Animation)AnimationUtils.loadAnimation(MainActivity.this, R.anim.list_anim);
LayoutAnimationController lac = new LayoutAnimationController(animation);
lac.setOrder(LayoutAnimationController.ORDER_NORMAL);
lac.setDelay(0.5f);
listView.setLayoutAnimation(lac);

这样,运行程序,显示的 ListView 就会按照 xml 文件中预置的动画效果显示了。

也可以通过 xml 文件进行设置动画:

① 在以上步骤的基础之上,在 res/anim 文件夹下创建一个 anim_layout.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
	android:delay="1"
	android:animationOrder="normal"
	android:animation="@anim/list_anim" />

② main 在布局文件的的 ListView 添加如下属性:

android:layoutAnimation="@anim/anim_layout"

这样就在把 MainActivity 的 onCreate () 方法中的
// 通过 Animation 获取 LayoutAnimationController 对 ListView 进行设置
注释后的代码删除了,直接使用 xml 进行动画的控制。

AnimationListener 的使用
public static interface
Animation.AnimationListener
android.view.animation.Animation.AnimationListener

An animation listener receives notifications from an animation. Notifications indicate animation related events, such as the end or the repetition of the animation.


包含以下的三个方法:

onAnimationEnd(Animation animation)
Notifies the end of the animation.
onAnimationRepeat(Animation animation)
Notifies the repetition of the animation.
onAnimationStart(Animation animation)
Notifies the start of the animation.
AnimationListener 在控件中的使用:

① 可以为一个 Button 添加一个事件:

button.setOnClickListener(new TestAnimationListener());

② 接下来是编写这个 TestAnimationListener 类,继承 AnimationListener,并覆盖里面的三个方法:

//这里获取控件组,R.id.layoutId为main.xml的整体布局标签的id属性值
ViewGroup viewGroup = (ViewGroup)findViewById(R.id.layoutId);

private class RemoveAnimationListener implements AnimationListener{
	//该方法在淡出效果执行结束之后被调用
	@Override
	public void onAnimationEnd(Animation animation) {
		//假设这里要在动画执行完之后删除一个TextView
		viewGroup.removeView(textView);
	}

	@Override
	public void onAnimationRepeat(Animation animation) {
		System.out.println("onAnimationRepeat");
	}

	@Override
	public void onAnimationStart(Animation animation) {
		System.out.println("onAnimationStart");
	}

}

③ 同样的,在动画效果中添加控件可以按照如下实现

ScaleAnimation scale = new ScaleAnimation(1, 0.5f, 1, 0.5f,
scale.setDuration(1000);
scale.setStartOffset(100);
TextView textView = new TextView(MainActivity.this);
textView.setText("add");
viewGroup.addView(textView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
textView.startAnimation(scale);

 

 

android.animation.TimeInterpolator的实例源码

android.animation.TimeInterpolator的实例源码

项目:Musicoco    文件:BottomNavigationController.java   
private void startTranslatePlayListAnim(float from,float to,int duration,final View view,@Nullable TimeInterpolator interpolator,@Nullable Animator.AnimatorListener listener) {
    final ValueAnimator anim = ObjectAnimator.ofFloat(from,to);
    anim.setDuration(duration);
    if (interpolator != null)
        anim.setInterpolator(interpolator);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float va = (float) animation.getAnimatedValue();
            view.setY(va);
        }
    });
    if (listener != null) {
        anim.addListener(listener);
    }
    anim.start();
}
项目:weex-3d-map    文件:DimensionUpdateListener.java   
@Override
public void onAnimationUpdate(ValueAnimator animation) {
  if (view.getLayoutParams() != null) {
    ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
    TimeInterpolator interpolator = animation.getInterpolator();
    float fraction = animation.getAnimatedFraction();
    if (width != null) {
      layoutParams.width = intEvaluator.evaluate(interpolator.getInterpolation(fraction),width.first,width.second);
    }
    if (height != null) {
      layoutParams.height = intEvaluator.evaluate(interpolator.getInterpolation(fraction),height.first,height.second);
    }
    view.requestLayout();
  }
}
项目:Virtualview-Android    文件:PageView.java   
private TimeInterpolator getTimeInterpolater() {
    switch (mAnimationStyle) {
        case ViewBaseCommon.ANIMATION_LINEAR:
            return new LinearInterpolator();
        case ViewBaseCommon.ANIMATION_DECELERATE:
            return new DecelerateInterpolator();
        case ViewBaseCommon.ANIMATION_ACCELERATE:
            return new AccelerateInterpolator();
        case ViewBaseCommon.ANIMATION_ACCELERATEDECELERATE:
            return new AccelerateDecelerateInterpolator();
        case ViewBaseCommon.ANIMATION_SPRING:
            return new SpringInterpolator();
        default:
            return new LinearInterpolator();
    }
}
项目:Depth    文件:ExitAnimation.java   
@Override
public void prepareAnimators(DepthRelativeLayout target,int index,int animationDelay) {
    final TimeInterpolator interpolator = new ExpoIn();

    final float finalTranslationY = exitConfiguration.getFinalYPercent() * target.getResources().getdisplayMetrics().heightPixels;
    final float finalTranslationX = exitConfiguration.getFinalXPercent() * target.getResources().getdisplayMetrics().widthPixels;

    final long totalDuration = exitConfiguration.getDuration();

    final ObjectAnimator translationY2 = ObjectAnimator.ofFloat(target,View.TRANSLATION_Y,finalTranslationY);
    translationY2.setDuration(totalDuration);
    //translationY2.setInterpolator(new AccelerateInterpolator());
    translationY2.setInterpolator(interpolator);
    translationY2.setStartDelay(animationDelay);
    attachListener(translationY2);
    add(translationY2);

    final ObjectAnimator translationX2 = ObjectAnimator.ofFloat(target,View.TRANSLATION_X,finalTranslationX);
    translationX2.setDuration(totalDuration);
    translationX2.setInterpolator(interpolator);
    translationX2.setStartDelay(animationDelay);
    add(translationX2);
}
项目:StaggeredAnimationGroup    文件:StaggeredAnimationGroupTest.java   
@Test
public void preparePartialTransition_setsPartialInterpolator() {
    //given
    final StaggeredAnimationGroup spiedGroup = prepareSpiedGroup();
    final TimeInterpolator testInterpolator = new LinearOutSlowInInterpolator();
    final Transition spiedTransition = spy(new AutoTransition());
    final StaggeredAnimationGroup.PartialTransitionFactory factory =
            new StaggeredAnimationGroup.PartialTransitionFactory() {
                @Override
                public Transition createPartialTransition(boolean show,int viewId,int indexInTransition) {
                    return spiedTransition;
                }
            };
    spiedGroup.setPartialTransitionFactory(factory);
    spiedGroup.setPartialInterpolator(testInterpolator);

    //when
    spiedGroup.preparePartialTransition(true,0);

    //then
    verify(spiedTransition,times(1)).setInterpolator(testInterpolator);
}
项目:android_additive_animations    文件:BaseAdditiveAnimator.java   
public T setInterpolator(TimeInterpolator interpolator) {
    if(mCurrentCustomInterpolator != null) {
        switchInterpolator(interpolator);
    } else {
        getValueAnimator().setInterpolator(interpolator);
    }
    return self();
}
项目:GitHub    文件:ViewAnimation.java   
/**
 * Set TimeInterpolator for all page animations.
 *
 * @param interpolator TimeInterpolator
 */
public void setTimeInterpolator(TimeInterpolator interpolator) {
    if (pageAnimations == null) return;
    for (ArrayList<PageAnimation> pageAnimationsInSamePage : pageAnimations) {
        if (pageAnimationsInSamePage == null) continue;
        for (PageAnimation pageAnimation : pageAnimationsInSamePage) pageAnimation.setTimeInterpolator(interpolator);
    }
}
项目:EasyTransition    文件:EasyTransition.java   
private static void runExitAnimation(final Activity activity,ArrayList<EasyTransitionoptions.ViewAttrs> attrs,long duration,TimeInterpolator interpolator) {
    if (null == attrs || attrs.size() == 0)
        return;

    for (final EasyTransitionoptions.ViewAttrs attr : attrs) {
        View view = activity.findViewById(attr.id);
        int[] location = new int[2];
        view.getLocationOnScreen(location);
        view.setPivotX(0);
        view.setPivotY(0);

        view.animate()
                .scaleX(attr.width / view.getWidth())
                .scaleY(attr.height / view.getHeight())
                .translationX(attr.startX - location[0])
                .translationY(attr.startY - location[1])
                .setInterpolator(interpolator)
                .setDuration(duration);
    }

    activity.findViewById(attrs.get(0).id).postDelayed(new Runnable() {
        @Override
        public void run() {
            activity.finish();
            activity.overridePendingTransition(0,0);
        }
    },duration);
}
项目:SimpleUILauncher    文件:PagedView.java   
protected void snapToPage(int whichPage,boolean immediate,TimeInterpolator interpolator) {
    whichPage = validateNewPage(whichPage);

    int newX = getScrollForPage(whichPage);
    final int delta = newX - getUnboundedScrollX();
    snapToPage(whichPage,delta,duration,immediate,interpolator);
}
项目:FlickLauncher    文件:PagedView.java   
protected void snapToPage(int whichPage,int delta,TimeInterpolator interpolator) {
    whichPage = validateNewPage(whichPage);

    mNextPage = whichPage;

    pageBeginMoving();
    awakenScrollBars(duration);
    if (immediate) {
        duration = 0;
    } else if (duration == 0) {
        duration = Math.abs(delta);
    }

    if (!mScroller.isFinished()) {
        abortScrollerAnimation(false);
    }

    if (interpolator != null) {
        mScroller.setInterpolator(interpolator);
    } else {
        mScroller.setInterpolator(mDefaultInterpolator);
    }

    mScroller.startScroll(getUnboundedScrollX(),duration);

    updatePageIndicator();

    // Trigger a compute() to finish switching pages if necessary
    if (immediate) {
        computeScroll();
    }

    mForceScreenScrolled = true;
    invalidate();
}
项目:LaunchEnr    文件:PagedView.java   
protected void snapToPage(int whichPage,interpolator);
}
项目:LaunchEnr    文件:PagedView.java   
protected void snapToPage(int whichPage,TimeInterpolator interpolator) {
    whichPage = validateNewPage(whichPage);

    mNextPage = whichPage;

    awakenScrollBars(duration);
    if (immediate) {
        duration = 0;
    } else if (duration == 0) {
        duration = Math.abs(delta);
    }

    if (duration != 0) {
        pageBeginTransition();
    }

    if (!mScroller.isFinished()) {
        abortScrollerAnimation(false);
    }

    if (interpolator != null) {
        mScroller.setInterpolator(interpolator);
    } else {
        mScroller.setInterpolator(mDefaultInterpolator);
    }

    mScroller.startScroll(getUnboundedScrollX(),duration);

    updatePageIndicator();

    // Trigger a compute() to finish switching pages if necessary
    if (immediate) {
        computeScroll();
        pageEndTransition();
    }

    invalidate();
}
项目:CSipSimple    文件:GlowPadView.java   
private void hideTargets(boolean animate,boolean expanded) {
    mTargetAnimations.cancel();
    // Note: these animations should complete at the same time so that we can swap out
    // the target assets asynchronously from the setTargetResources() call.
    mAnimatingTargets = animate;
    final int duration = animate ? HIDE_ANIMATION_DURATION : 0;
    final int delay = animate ? HIDE_ANIMATION_DELAY : 0;

    final float targetScale = expanded ?
            TARGET_SCALE_EXPANDED : TARGET_SCALE_COLLAPSED;
    final int length = mTargetDrawables.size();
    final TimeInterpolator interpolator = Ease.Cubic.eaSEOut;
    for (int i = 0; i < length; i++) {
        TargetDrawable target = mTargetDrawables.get(i);
        target.setState(TargetDrawable.STATE_INACTIVE);
        mTargetAnimations.add(Tweener.to(target,"ease",interpolator,"alpha",0.0f,"scaleX",targetScale,"scaleY","delay",delay,"onUpdate",mUpdateListener));
    }

    float ringScaleTarget = expanded ?
            RING_SCALE_EXPANDED : RING_SCALE_COLLAPSED;
    ringScaleTarget *= mRingScaleFactor;
    mTargetAnimations.add(Tweener.to(mOuterRing,ringScaleTarget,mUpdateListener,"onComplete",mTargetUpdateListener));

    mTargetAnimations.start();
}
项目:Musicoco    文件:AnimationUtils.java   
public static void startTranslateYAnim(float from,@Nullable TimeInterpolator interpolator) {
    final ValueAnimator anim = ObjectAnimator.ofFloat(from,to);
    anim.setDuration(duration);
    if (interpolator != null)
        anim.setInterpolator(interpolator);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float va = (float) animation.getAnimatedValue();
            view.setY(va);
        }
    });
    anim.start();
}
项目:Farmacias    文件:ExpandableLinearLayout.java   
/**
 * {@inheritDoc}
 */
@Override
public void toggle(final long duration,final @Nullable TimeInterpolator interpolator) {
    if (closePosition < getCurrentPosition()) {
        collapse(duration,interpolator);
    } else {
        expand(duration,interpolator);
    }
}
项目:Farmacias    文件:ExpandableLinearLayout.java   
/**
 * {@inheritDoc}
 */
@Override
public void expand(final long duration,final @Nullable TimeInterpolator interpolator) {
    if (isAnimating) return;

    if (duration <= 0) {
        move(layoutSize,interpolator);
        return;
    }
    createExpandAnimator(getCurrentPosition(),layoutSize,interpolator).start();
}
项目:Farmacias    文件:ExpandableLinearLayout.java   
/**
 * {@inheritDoc}
 */
@Override
public void collapse(final long duration,final @Nullable TimeInterpolator interpolator) {
    if (isAnimating) return;

    if (duration <= 0) {
        move(closePosition,closePosition,interpolator).start();
}
项目:Farmacias    文件:Utils.java   
/**
 * Creates interpolator.
 *
 * @param interpolatorType
 * @return
 */
public static TimeInterpolator createInterpolator(@IntRange(from = 0,to = 10) final int interpolatorType) {
    switch (interpolatorType) {
        case ACCELERATE_DECELERATE_INTERPOLATOR:
            return new AccelerateDecelerateInterpolator();
        case ACCELERATE_INTERPOLATOR:
            return new AccelerateInterpolator();
        case ANTICIPATE_INTERPOLATOR:
            return new AnticipateInterpolator();
        case ANTICIPATE_OVERSHOOT_INTERPOLATOR:
            return new AnticipateOvershootInterpolator();
        case BOUNCE_INTERPOLATOR:
            return new BounceInterpolator();
        case DECELERATE_INTERPOLATOR:
            return new DecelerateInterpolator();
        case FAST_OUT_LINEAR_IN_INTERPOLATOR:
            return new FastOutLinearInInterpolator();
        case FAST_OUT_SLOW_IN_INTERPOLATOR:
            return new FastOutSlowInInterpolator();
        case LINEAR_INTERPOLATOR:
            return new LinearInterpolator();
        case LINEAR_OUT_SLOW_IN_INTERPOLATOR:
            return new LinearOutSlowInInterpolator();
        case OVERSHOOT_INTERPOLATOR:
            return new OvershootInterpolator();
        default:
            return new LinearInterpolator();
    }
}
项目:Orin    文件:FlatPlayerPlaybackControlsFragment.java   
private static void addAnimation(Collection<Animator> animators,View view,TimeInterpolator interpolator,int delay) {
    Animator scaleX = ObjectAnimator.ofFloat(view,View.SCALE_X,0f,1f);
    scaleX.setInterpolator(interpolator);
    scaleX.setDuration(duration);
    scaleX.setStartDelay(delay);
    animators.add(scaleX);

    Animator scaleY = ObjectAnimator.ofFloat(view,View.SCALE_Y,1f);
    scaleY.setInterpolator(interpolator);
    scaleY.setDuration(duration);
    scaleY.setStartDelay(delay);
    animators.add(scaleY);
}
项目:FlickLauncher    文件:PagedView.java   
protected void snapToPage(int whichPage,interpolator);
}
项目:Mire    文件:TransitionAnimation.java   
public static MoveData startAnimation(Context context,final View toView,Bundle transitionBundle,Bundle savedInstanceState,final int duration,final TimeInterpolator interpolator) {
    final TransitionData transitionData = new TransitionData(context,transitionBundle);
    if (transitionData.imageFilePath != null) {
        setimageToView(toView,transitionData.imageFilePath);
    }
    final MoveData moveData = new MoveData();
    moveData.toView = toView;
    moveData.duration = duration;
    if (savedInstanceState == null) {

        ViewTreeObserver observer = toView.getViewTreeObserver();
        observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                toView.getViewTreeObserver().removeOnPreDrawListener(this);

                int[] screenLocation = new int[2];
                toView.getLocationOnScreen(screenLocation);
                moveData.leftDelta = transitionData.thumbnailLeft - screenLocation[0];
                moveData.topDelta = transitionData.thumbnailTop - screenLocation[1];

                moveData.widthScale = (float) transitionData.thumbnailWidth / toView.getWidth();
                moveData.heightScale = (float) transitionData.thumbnailHeight / toView.getHeight();

                runEnteranimation(moveData,interpolator);

                return true;
            }
        });
    }
    return moveData;
}
项目:Mire    文件:TransitionAnimation.java   
private static void runEnteranimation(MoveData moveData,TimeInterpolator interpolator) {
    final View toView = moveData.toView;
    toView.setPivotX(0);
    toView.setPivotY(0);
    toView.setScaleX(moveData.widthScale);
    toView.setScaleY(moveData.heightScale);
    toView.setTranslationX(moveData.leftDelta);
    toView.setTranslationY(moveData.topDelta);

    toView.animate().setDuration(moveData.duration).
            scaleX(1).scaleY(1).
            translationX(0).translationY(0).
            setInterpolator(interpolator);
}
项目:LiveGiftLayout    文件:GiftAnimationUtil.java   
/**
 * @param target
 * @param star     动画起始坐标
 * @param end      动画终止坐标
 * @param duration 持续时间
 * @return 创建一个从左到右的飞入动画
 * 礼物飞入动画
 */
public static ObjectAnimator createFlyFromLtoR(final View target,float star,float end,TimeInterpolator interpolator) {
    //1.个人信息先飞出来
    ObjectAnimator anim1 = ObjectAnimator.ofFloat(target,"translationX",star,end);
    anim1.setInterpolator(interpolator);
    anim1.setDuration(duration);
    return anim1;
}
项目:GitHub    文件:RevealVisibilityTransition.java   
@Override
public TimeInterpolator getInterpolator() {
    return mAnimator.getInterpolator();
}
项目:GitHub    文件:RevealVisibilityTransition.java   
@Override
public void setInterpolator(TimeInterpolator timeInterpolator) {
    mAnimator.setInterpolator(timeInterpolator);
}
项目:GitHub    文件:PauseableAnimator.java   
@Override public void setInterpolator(TimeInterpolator value) {
  mWrappedAnimator.setInterpolator(value);
}
项目:MusicX-music-player    文件:ProgressBar.java   
public void setAnimInterpolator(@NonNull TimeInterpolator timeInterpolator) {
    mProgressAnimator.setInterpolator(timeInterpolator);
    mMaxAnimator.setInterpolator(timeInterpolator);
}
项目:SmartOrnament    文件:GuillotineAnimation.java   
public GuillotineBuilder setInterpolator(TimeInterpolator interpolator) {
    this.interpolator = interpolator;
    return this;
}
项目:GitHub    文件:WoWoTranslationAnimation.java   
private WoWoTranslationAnimation(int page,float startOffset,float endOffset,int ease,boolean useSameEaseEnumBack,float fromX,float fromY,float toX,float toY) {
    super(page,startOffset,endOffset,ease,useSameEaseEnumBack,fromX,fromY,toX,toY);
}
项目:SimpleUILauncher    文件:LauncherScroller.java   
public void setInterpolator(TimeInterpolator interpolator) {
    mInterpolator = interpolator;
}
项目:GitHub    文件:WoWoPathAnimation.java   
private WoWoPathAnimation(int page,WoWoPathView pathView,float fromProcess,float toProcess) {
    super(page,useSameEaseEnumBack);
    this.pathView = pathView;
    this.fromProcess = fromProcess;
    this.toProcess = toProcess;
}
项目:GitHub    文件:WoWoPosition3DAnimation.java   
private WoWoPosition3DAnimation(int page,float fromZ,float toY,float toZ) {
    super(page,fromZ,toY,toZ);
}
项目:GitHub    文件:TextPageAnimation.java   
public TextPageAnimation(int page,String fromText,String toText,Typewriter typewriter) {
    super(page,useSameEaseEnumBack);
    this.fromText = fromText;
    this.toText = toText;
    this.typewriter = typewriter;
}
项目:GitHub    文件:WoWoShapeColorAnimation.java   
private WoWoShapeColorAnimation(int page,Integer fromColor,Integer toColor,Chameleon chameleon) {
    super(page,fromColor,toColor,chameleon);
}
项目:SimpleUILauncher    文件:DeleteDropTarget.java   
@Override
public void onFlingToDelete(final DragObject d,PointF vel) {
    // Don't highlight the icon as it's animating
    d.dragView.setColor(0);

    final DragLayer dragLayer = mLauncher.getDragLayer();
    FlingAnimation fling = new FlingAnimation(d,vel,getIconRect(d.dragView.getMeasuredWidth(),d.dragView.getMeasuredHeight(),mDrawable.getIntrinsicWidth(),mDrawable.getIntrinsicHeight()),dragLayer);

    final int duration = fling.getDuration();
    final long startTime = AnimationUtils.currentAnimationTimeMillis();

    // NOTE: Because it takes time for the first frame of animation to actually be
    // called and we expect the animation to be a continuation of the fling,we have
    // to account for the time that has elapsed since the fling finished.  And since
    // we don't have a startDelay,we will always get call to update when we call
    // start() (which we want to ignore).
    final TimeInterpolator tInterpolator = new TimeInterpolator() {
        private int mCount = -1;
        private float mOffset = 0f;

        @Override
        public float getInterpolation(float t) {
            if (mCount < 0) {
                mCount++;
            } else if (mCount == 0) {
                mOffset = Math.min(0.5f,(float) (AnimationUtils.currentAnimationTimeMillis() -
                        startTime) / duration);
                mCount++;
            }
            return Math.min(1f,mOffset + t);
        }
    };

    Runnable onAnimationEndRunnable = new Runnable() {
        @Override
        public void run() {
            mLauncher.exitSpringLoadedDragMode();
            completeDrop(d);
            mLauncher.getDragController().onDeferredEndFling(d);
        }
    };

    dragLayer.animateView(d.dragView,fling,tInterpolator,onAnimationEndRunnable,DragLayer.ANIMATION_END_disAPPEAR,null);
}
项目:GitHub    文件:WowoelevationAnimation.java   
private WowoelevationAnimation(int page,float fromElevation,float toElevation) {
    super(page,useSameEaseEnumBack);
    this.fromElevation = fromElevation;
    this.toElevation = toElevation;
}
项目:GitHub    文件:WoWoPositionAnimation.java   
private WoWoPositionAnimation(int page,toY);
}
项目:GitHub    文件:WoWoTextViewTextAnimation.java   
public WoWoTextViewTextAnimation(int page,fromText,toText,typewriter);
}
项目:FlowLine    文件:FlowLineView.java   
public void start() {
    ValueAnimator mAnimator = ValueAnimator.ofInt(360,0);
    mAnimator.setDuration(10 * 360);
    mAnimator.setRepeatCount(ValueAnimator.INFINITE);
    mAnimator.setInterpolator(new TimeInterpolator() {

        @Override
        public float getInterpolation(float input) {
            return input;
        }
    });
    mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Integer value = (Integer) animation.getAnimatedValue();
            startLinePoint = value / 360f;
            endLinePoint = startLinePoint + 0.5f;
            if (startLinePoint > 0.5f) {
                offsetLinePoint = startLinePoint - 0.5f;
                int splitColor = Color.argb((int) (255 * (offsetLinePoint / 0.5f)),255,0);
                colorArray =
                        new int[]{splitColor,0x00FF0000,0xFFFF0000,splitColor};
                pathArray =
                        new float[]{0f,offsetLinePoint,startLinePoint,1f};
            } else {
                colorArray =
                        new int[]{0,0};
                pathArray =
                        new float[]{0f,endLinePoint,1f};
            }

            SweepGradient mShader = new SweepGradient(250,250,colorArray,pathArray);
            mBitmapPaint.setShader(mShader);
            mBitmapCanvas.drawColor(Color.TRANSPARENT,PorterDuff.Mode.CLEAR);
            mBitmapCanvas.drawPath(mPath,mBitmapPaint);
            postInvalidate();
        }
    });
    mAnimator.start();
}
项目:AndroidOpen    文件:PlayTransition.java   
@Override
public TimeInterpolator getInterpolator() {
    return mAnimator.getInterpolator();
}

我们今天的关于scipy.ndimage.interpolation.rotate之后旋转的图像坐标?scipy rotation的分享就到这里,谢谢您的阅读,如果想了解更多关于android – applyTransformation用interpolatedTime == 1调用两次、android – 使用ACTION_IMAGE_CAPTURE拍摄的图像在某些Gingerbread设备上的ExifInterface.TAG_ORIENTATION返回1、Android 中使用 Animation 实现控件的动画效果以及 Interpolator 和 AnimationListener 的使用、android.animation.TimeInterpolator的实例源码的相关信息,可以在本站进行搜索。

本文标签: