- 浏览: 252527 次
- 性别:
- 来自: 太原
最新评论
-
kinglo:
请问生成的文件怎么看?
Android 全局异常处理 -
yong7356:
学习一下。。。。。
Android Ant -
bzlring:
很好
Android 全局异常处理 -
M985300651:
難得一見的好教學
Android 自定义滚动视图 -
i5suoi:
thank you very much
Android 全局异常处理
MainActivity
package org.wp.activity; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MainActivity extends Activity { private ImageView myImageView = null; private Button myButton = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); myImageView = (ImageView) this.findViewById(R.id.myImageView); myButton = (Button) this.findViewById(R.id.myButton); myButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myImageView.startAnimation(new TVOffAnimation()); } }); } }
TVOffAnimation
package org.wp.activity; import android.graphics.Matrix; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Animation; import android.view.animation.Transformation; public class TVOffAnimation extends Animation { /** 中心点X坐标 **/ private int centerX = 0; /** 中心点Y坐标 **/ private int centerY = 0; @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { // void setDuration (long durationMillis) // Since: API Level 1 How long this animation should last. // The duration cannot be negative. setDuration(500); // void setFillAfter(boolean fillAfter) // If fillAfter is true, the transformation that this animation // performed will persist when it is finished. setFillAfter(true); // 获得图片中心点X坐标 centerX = width / 2; // 获得图片中心点Y坐标 centerY = height / 2; // void setInterpolator (Interpolator i) // Since: API Level 1 Sets the acceleration curve for this animation. // Defaults to a linear interpolation. // setInterpolator(new AccelerateDecelerateInterpolator()) // 选择一个速度的效果 // AccelerateDecelerateInterpolator // An interpolator where the rate of change starts and ends slowly // but accelerates through the middle. setInterpolator(new AccelerateDecelerateInterpolator()); } /** * preScale(float sx, float sy, float px, float py) * px 和 py 是固定点, * 例如 px,py=0,0 的话, * 图像会以左上角为基点,向右向下放大缩小。 * * 如果是图中心的话,图像便会以图中心为基点, * 向上下左右等比例的放大缩小。 * * 一般情况下,如果图像的内部座标不重要的话, * 只用preScale(sy, sy)就可以了。 * 要用到px,py的情况,通常是前后还有牵涉Animation的运作。 * * 简单讲,放大比例不会改变,都是按sx和sy决定。 * 只是px,py那点,在放大前和放大后都会不变。 * * 例如: 一个(width)20 (height)10的长方形, * 左上角座标是(0,0)。那右下角是(20,10)。 * 如果sx,sy=2,2 即放大两倍。 * 当px ,py=0,0放大后,左上角仍然是(0,0),但右下角会变成(40,20)。 * * 但同样是sx,sy=2,2,但px,py=10,5的话, * 放大后,左上角会是(-10,-5)而右下角会是(30,15)。 * 唯一座标不变的就只有10,5 那点。但长方形仍然会放大两倍。 * * 看上去没有什么不同,但如果用上Animation的话, * 因为Animation对座标是有要求,所以效果也会有不同。 * * * interpolatedTime 表示的是当前动画的间隔时间 范围是0-1 * * 那么横向来讲前80%的时间我们要横向拉伸到150%, * 变化的速率为 0.5 / 0.8 = 0.625 * 所以横向缩放值为 1 + 0.625f * interpolatedTime * * 纵向在前80%的时间是直接减小,最后只留一条高度为0.01f的线。 * 变化的速率为 1 / 0.8 = 1.25 * 所以纵向缩放值为 1 - 1.25f * interpolatedTime + 0.01f * 当然也可以写成 1 - interpolatedTime / 0.8f + 0.01f * * 后20%的时间里我们要横向从150%压缩至0%, * 变化的速率为 1.5 / 0.2 = 7.5 * 所以横向缩放值为 7.5f * (1 - interpolatedTime) * * 纵向保持不变就好了,当横向为0的时候就全部消失了。 */ @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final Matrix matrix = t.getMatrix(); if (interpolatedTime < 0.8) { matrix.preScale(1 + 0.625f * interpolatedTime, 1 - 1.25f * interpolatedTime + 0.01f, centerX, centerY); } else { matrix.preScale(7.5f * (1 - interpolatedTime), 0.01f, centerX, centerY); } } }
main.xml
<?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="vertical" android:gravity="center"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg" android:id="@+id/myImageView" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20dip" android:text="power off" android:id="@+id/myButton" /> </LinearLayout>
发表评论
-
Android Gallery3D
2011-11-28 10:51 1984MainActivity package org.wp ... -
Android 自定义Gallery
2011-10-19 21:33 2921MainActivity package org.wp.ac ... -
Android 3D图片切换
2011-10-14 17:19 3497MainActivity package org.wp.ac ... -
Android C2DM
2011-10-07 16:36 2232AndroidC2DMDemo com.google. ... -
Android Ant
2011-10-03 20:31 2893build.xml <?xml version=&qu ... -
Android 图片倒影
2011-09-09 11:07 6299MainActivity package org.wp.ac ... -
Android 自定义滚动视图
2011-09-08 15:03 6860MainActivity package org.wp.ac ... -
Android 绘制心形
2011-09-06 15:18 6732MyLove package org.wp.activity ... -
Android 播放音频文件
2011-09-05 16:31 5824MainActivity package org.wp.ac ... -
Android 添加自定义SurfaceView
2011-08-29 17:19 7516MainActivity package org.wp.ac ... -
Android Looper
2011-08-28 11:10 2280LooperActivity package org.wp. ... -
Android AsyncTask
2011-08-27 15:21 1565AsyncTaskActivity package org. ... -
Android TimerTask
2011-08-26 22:16 4504TimerTaskActivity package org. ... -
Android Thread
2011-08-26 13:59 5610ThreadActivity package org.wp. ... -
Android 判断程序前后台状态
2011-08-25 13:26 6888AppStatusService package org.w ... -
注册界面
2011-08-23 20:57 1192MainActivity package org.wp.ac ... -
Android 半透明(二)
2011-08-18 20:02 1505TranslucentBlurActivity packag ... -
Android 半透明(一)
2011-08-18 17:08 1661TranslucentActivity package or ... -
游戏角色在屏幕行走
2011-08-18 11:32 1242MySurfaceView package org.wp.a ... -
Android SurfaceView基础
2011-08-17 15:01 1605MySurfaceView package org.wp.a ...
相关推荐
android 电视关机动画,模拟2.3系统待机动画
android 开关机动画设计,描述开机,关机动画的设计方式
用于指令切换android系统的开关机动画,主要用于特定移动开发定制需要
android开关机动画和铃声配置,MTK,SPD平台
android开关机动画开关机铃声修改方法
精美开关机动画,还有如何制作开关机动画,有想了解的可以给我留言。
10.0添加关机音乐和关机动画的功能
主要介绍了Android 修改系统关机动画的实现的相关资料,需要的朋友可以参考下
Android 12 开关机动画客制化patch
6820默认是没有播放自定义开关机动画和铃声,本代码主要包含了展讯开机与关机的动画和铃声代码、资源
Android S MTK平台开机Logo与开机动画的资源文件。
如何替换与制作安卓手机开关机动画方法: http://www.liangston.com/?post=346 有Root权限后,打开RE管理器Root Explore,进入到进入system/media目录下, 将解压开的 bootanimation.zip Bootsound.mp3 ...
此文档详细介绍了非运营商如何客制化开关机动画。开关机铃声
系统通常默认支持开机动画,开机关机铃声服务倒是预先定义了,不过使用...长按Power键 弹出关键选项,关机时也只是显示进度条,而不是我们期望的关机动画同时伴有关机铃声,当然在做二次开发的时候,这些都是可以定制的
开机到android中充电动画显示的大致流程解析
android 6.0 开机 关机 动画 铃声 添加
电量低于设定值时,插到充电器时进入uboot充电状态,电量大于设定值时自动重启;内核dts配置请参考dts.txt说明
Android例子源码模仿安卓微信、云播雷达扫描动画效果 Android例子源码类似58同城的通过滑屏控制引导页 Android例子源码计步器圆形UI设计 Android例子源码适合新手学习的listview使用源码 android及时通讯源码 ...
Android败家之眼开机关机动画