- 浏览: 3900354 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
hinuliba:
...
字体背景颜色的高度修改 -
KANGOD:
最后的 -createDialog() 私有方法是怎么回事,没 ...
简单的实现listView中item多个控件以及点击事件 -
sswangqiao:
呵呵,呵呵
onActivityResult传值的使用 -
yumeiqiao:
感觉你所的不清楚 lstView.setOnTouchLi ...
listview中viewflipper的问题 -
lizhou828:
果然是大神啊!!!
Animation动画效果的实现
用到animation-list其实就是帧叠加 ,通常要注意两个问题
1.一般布局要用在frameLayout
2.它呢一般作为背景 然后在取出来
public class EarthAnimationActivity extends Activity { private static final String TAG = "EarthAnimationActivity"; protected static final int FORWARD = 0; protected static final int REVERSE = 1; private Button earthButton; private AnimationDrawable earthButtonAnimation; protected int direction; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); earthButton = (Button) findViewById(R.id.earth_button); earthButtonAnimation = (AnimationDrawable) earthButton.getBackground(); direction = FORWARD; earthButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if ( ! earthButtonAnimation.isRunning() ) { earthButtonAnimation.start(); earthButton.setText(R.string.click_me_to_stop); } else { earthButtonAnimation.stop(); int resId = R.anim.earth_animation_rev; if ( direction == FORWARD ) { direction = REVERSE; } else { resId = R.anim.earth_animation; direction = FORWARD; } earthButton.setBackgroundResource(resId); earthButtonAnimation = (AnimationDrawable) earthButton.getBackground(); earthButton.setText(R.string.click_me_to_start); } } }); } /* (non-Javadoc) * @see android.app.Activity#onResume() */ @Override protected void onResume() { super.onResume(); (new Timer(false)).schedule(new AnimationTimer(earthButtonAnimation), 100); } /* (non-Javadoc) * @see android.app.Activity#onPause() */ @Override protected void onPause() { super.onPause(); earthButtonAnimation.stop(); } private static class AnimationTimer extends TimerTask { AnimationDrawable animation; public AnimationTimer(AnimationDrawable animation) { this.animation = animation; } @Override public void run() { animation.start(); this.cancel(); } } }
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/frame_layout" android:background="@drawable/space_background"> <Button android:id="@+id/earth_button" android:background="@anim/earth_animation" android:text="@string/click_me_to_stop" android:layout_gravity="center" android:textStyle="bold" android:textColor="#ff9900" android:layout_marginBottom="12dip" android:layout_marginRight="12dip" android:layout_marginTop="12dip" android:maxHeight="296dip" android:maxWidth="296dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:width="296dip" android:height="296dip" android:layout_marginLeft="-10dip" android:textSize="24dip"></Button> </FrameLayout>
上面主vxml
下面是地球的正反旋转
<?xml version="1.0" encoding="UTF-8"?> <!-- Animation frames for earth --> <!-- android:id="@+id/earth_animation" --> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" android:visible="true"> <item android:drawable="@drawable/earth0" android:duration="150" /> <item android:drawable="@drawable/earth1" android:duration="150" /> <item android:drawable="@drawable/earth2" android:duration="150" /> <item android:drawable="@drawable/earth3" android:duration="150" /> <item android:drawable="@drawable/earth4" android:duration="150" /> <item android:drawable="@drawable/earth5" android:duration="150" /> <item android:drawable="@drawable/earth6" android:duration="150" /> <item android:drawable="@drawable/earth7" android:duration="150" /> <item android:drawable="@drawable/earth8" android:duration="150" /> <item android:drawable="@drawable/earth9" android:duration="150" /> </animation-list>
<?xml version="1.0" encoding="UTF-8"?> <!-- Animation frames for earth --> <!-- android:id="@+id/earth_animation_rev" --> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" android:visible="true"> <item android:drawable="@drawable/earth9" android:duration="150" /> <item android:drawable="@drawable/earth8" android:duration="150" /> <item android:drawable="@drawable/earth7" android:duration="150" /> <item android:drawable="@drawable/earth6" android:duration="150" /> <item android:drawable="@drawable/earth5" android:duration="150" /> <item android:drawable="@drawable/earth4" android:duration="150" /> <item android:drawable="@drawable/earth3" android:duration="150" /> <item android:drawable="@drawable/earth2" android:duration="150" /> <item android:drawable="@drawable/earth1" android:duration="150" /> <item android:drawable="@drawable/earth0" android:duration="150" /> </animation-list>
- AndroidEarthAnimation.rar (197.7 KB)
- 下载次数: 481
发表评论
-
URI 转path
2019-06-26 10:41 1218转自知乎Matisse package com.zhihu ... -
权限申请
2017-09-22 13:25 1221public class PermissionActivit ... -
onPreviewFrame 相机输出格式转换yuv420p保存成图片
2015-11-25 15:59 7480在最近项目中,因为特殊需要,底层相机往外输出了i420 也 ... -
new Android's Runtime Permission
2015-11-03 21:05 1189targetSdkVersion 23 开始 使用运行时权 ... -
自定义listview 边缘效果
2015-02-28 10:58 1696static void ChangeEdgeEffect( ... -
发射打开wifi
2015-01-07 10:25 1370WifiManager wifiManager = (Wif ... -
RecyclerView
2014-11-05 13:08 1205http://www.grokkingandroid.com ... -
获取点击区域
2014-04-28 09:39 1513@Override public void getHitR ... -
speex 和libogg 编译
2014-04-03 16:17 6363下载: http://www.speex.org/down ... -
rsync 同步
2014-03-28 17:06 1795两台android 设备 进行rsy ... -
流转字符串
2014-03-11 09:49 1475public static String convertSt ... -
java simplexml 序列化
2014-03-06 13:22 5880<?xml version="1.0&quo ... -
获取其他程序的特定资源
2014-03-05 09:33 1652try { PackageManager man ... -
检测来电属于哪个sim卡
2014-02-07 10:41 1674public class IncomingCallInter ... -
使用 NDK r9 编译ffmpeg
2014-01-16 13:32 167551. 环境 ubuntu 我的是13.10 ndk r9 ... -
android h264含so
2014-01-13 11:24 1503http://download.csdn.net/downlo ... -
xml转义字符
2013-12-18 09:29 1550" " ' & ... -
字体背景颜色的高度修改
2013-12-11 10:31 4133当使用android:lineSpacingExtra= ... -
屏保的实现
2013-12-07 10:27 2716最近需要做一个屏保,开始以为很简单,因为系统本身就带了屏保功 ... -
PreferenceActivity下嵌套PreferenceScreen在其它布局中
2013-11-21 16:32 9095今天在修改系统代码的时候,系统代码用了PreferenceA ...
相关推荐
C语言02-Timer0-Timer1-Timer2-Timer3-Timer4测试程序(STC32G-DEMO-CODE-220311kw)C语言02-Timer0-Timer1-Timer2-Timer3-Timer4测试程序(STC32G-DEMO-CODE-220311kw)C语言02-Timer0-Timer1-Timer2-Timer3-Timer4...
如果您使用 Expo 创建一个项目,“”。 expo eject 安装 React Native 后台计时器包。 yarn add react-native-background-timer # or using npm npm install react-native-background-timer --save 链接 React ...
React/React本地倒数循环计时器 圆形/带颜色和进度动画的React / React Native倒数计时器组件。 倒计时动画针对Web和移动进行了独立优化 倒计时期间颜色之间的过渡 ... 阅读安装指南的以及演示和用例。 React /
hal-adc-dma-timer.rar
STC8a8k所有定时器测试程序
这里有实验所用到的源代码和实验报告,对同学们非常有用。。。实验报告给大家作为参考 简介: 实验目的 熟练掌握外部中断原理、外部中断响应方式...了解Timer工作原理及其中断产生方式及响应方式,掌握Timer控制方法。
NULL 博文链接:https://675990021.iteye.com/blog/2265945
工业机器人-Remanent On-delayTimer for S7-300400.7z
eslint-plugin-clean-timer 使用setTimeout和setInterval实施最佳实践动机它总是容易忘记清除通过设置定时器setTimeout或setInterval ,这可能会导致那些不易发现的错误。 使用以下代码对具有onMount和onUnmount生命...
React本地倒数计时器Countdown Timer移动应用程序是使用React Native和Expo构建的。 它只是一个倒数计时器,允许用户添加分钟,然后开始,暂停或加速倒数。屏幕截图项目规格: 该项目是一个倒数计时器。 用户输入...
西门子PLC例程-Remanent On-delayTimer for S7-300400.zip
12-2-1-定时器 Timer-相关例程演示 12-2-2-定时器 Timer-特性及时钟 12-2-3-定时器 Timer-模式
29-DEMO-使用Timer0做16路软件PWM29-DEMO-使用Timer0做16路软件PWM
在S7-300 S7-400和S7-1200 S7-1500中编程IEC Timer时应该注意什么
这是Java两种功能的比较。。。里面涉及到一些使用
02-Timer0-Timer1-Timer2测试程序_STC15W408AS跑马灯程序_源码.zip
反时间限制,让许多试用版软件没有时间限制
Android---Service Timer之执行周期任务
定义一个定时器,每隔一段时间就访问一次串口.