Tween动画

1.在关闭电视机的时候,电视机中间都有一根白条瞬间关闭。

  要实现这个效果其实就是利用Tween动画进行实现的。

动画的xml 文件是:

    android:startOffset=""  利用这个属性可以实现动画执行的先后顺序

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:shareInterpolator="false"
  4. android:zAdjustment="top" >
  5.  
  6. <scale
  7. android:duration="5000"
  8. android:fromXScale="1.0"
  9. android:fromYScale="1.0"
  10. android:interpolator="@android:anim/accelerate_interpolator"
  11. android:pivotX="50%"
  12. android:pivotY="50%"
  13. android:toXScale="1.0"
  14. android:toYScale="0.003" />
  15. <scale
  16. android:duration="3000"
  17. android:fromXScale="1.0"
  18. android:fromYScale="1.0"
  19. android:interpolator="@android:anim/accelerate_interpolator"
  20. android:pivotX="50%"
  21. android:pivotY="50%"
  22. android:startOffset="5000"
  23. android:toXScale="0.0"
  24. android:toYScale="0.3" />
  25.  
  26. <alpha
  27. android:duration="3000"
  28. android:fillAfter="true"
  29. android:fillEnabled="true"
  30. android:fromAlpha="1.0"
  31. android:interpolator="@android:anim/accelerate_interpolator"
  32. android:startOffset="5000"
  33. android:toAlpha="0" />
  34.  
  35. <rotate
  36. android:fromDegrees="0.0"
  37. android:toDegrees="360.0"
  38. android:pivotX="50%"
  39. android:pivotY="50%"
  40. android:fillAfter="true"
  41. android:interpolator="@android:anim/linear_interpolator"
  42. android:duration="5000"
  43. />
  44.  
  45. </set>

主界面的Activity

  1. public class MainActivity extends Activity {
  2.  
  3. private ImageView back , line;
  4.  
  5. private Animation mAnimation;
  6. @Override
  7. protected void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. setContentView(R.layout.activity_main);
  10. initView();
  11. }
  12.  
  13. private void initView() {
  14. back = (ImageView)findViewById(R.id.img_back);
  15. line = (ImageView)findViewById(R.id.img_line);
  16. mAnimation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.tv_off);
  17. mAnimation.setAnimationListener(new AnimationListener() {
  18.  
  19. @Override
  20. public void onAnimationStart(Animation animation) {
  21.  
  22. }
  23.  
  24. @Override
  25. public void onAnimationRepeat(Animation animation) {
  26.  
  27. }
  28.  
  29. @Override
  30. public void onAnimationEnd(Animation animation) {
  31.  
  32. }
  33. });
  34.  
  35. line.setVisibility(View.VISIBLE);
  36. line.setAnimation(mAnimation);
  37. // mAnimation.start();
  38.  
  39. }
  40.  
  41. }
  1. activity_main.xml:
  1. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context=".MainActivity" >
  6.  
  7. <ImageView
  8. android:id="@+id/img_back"
  9. android:layout_width="match_parent"
  10. android:layout_height="match_parent"
  11. android:background="@color/black" />
  12.  
  13. <ImageView
  14. android:id="@+id/img_line"
  15. android:layout_width="match_parent"
  16. android:layout_height="match_parent"
  17. android:background="@color/white"
  18. android:visibility="gone"
  19. />
  20.  
  21. </FrameLayout>

源码下载

Android 模仿电视机关闭界面的更多相关文章

  1. Android WebView无法播放视频或直播,关闭界面后任在播放的问题;

    1.设置webview属性: webView.setWebChromeClient(new MyWebChromeClient());         webSettings = webView.ge ...

  2. [转]Android:布局实例之模仿QQ登录界面

    Android:布局实例之模仿QQ登录界面 预览图: 准备: 1.找到模仿对象 QQ登陆界面UI下载>>>>> 2.导入工程 3.查看布局结构和使用控件 其对应效果图分布 ...

  3. Android:布局实例之模仿QQ登录界面

    预览图: 准备: 1.找到模仿对象 QQ登陆界面UI下载>>>>> 2.导入工程 3.查看布局结构和使用控件 其对应效果图分布为 4.分析样式选择器 下拉箭头2种样式:点 ...

  4. Android:布局实例之模仿京东登录界面

    预览图及布局结构参考: 布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout ...

  5. android studio 新建项目 界面一直停在 【“building ‘ 项目名’ gradle project info”】

    zhezhelin android studio 新建项目 界面一直停在 [“building ‘ 项目名’ gradle project info”] 安装了android studio 之后,按照 ...

  6. Android模仿iOS iMessages10照片选择器的实现

    不知不觉已经接近半年多没有写过博客了,这段时间,也是我刚好毕业走出校园的时间,由于学习工作的原因,一直没有真正静下心来写下些什么东西.这个星期刚入了小米笔记本pro的坑,本着新电脑新生活的理念嘻嘻-- ...

  7. android 仿微信聊天界面,以及语音录制功能

    extends:http://104zz.iteye.com/blog/1709840 本例为模仿微信聊天界面UI设计,文字发送以及语言录制UI. 1先看效果图:     第一:chat.xml设计 ...

  8. Android ActionBar仿微信界面

    ActionBar仿微信界面 1.学习了别人的两篇关于ActionBar博客,在结合别人的文章来仿造一下微信的界面: 思路如下:1).利用ActionBar生成界面的头部,在用ActionBar的Ac ...

  9. Stack Overflow 排错翻译 - Closing AlertDialog.Builder in Android -Android环境中关闭AlertDialog.Builder

    Stack Overflow 排错翻译  - Closing AlertDialog.Builder in Android -Android环境中关闭AlertDialog.Builder 转自:ht ...

随机推荐

  1. 【英语】Bingo口语笔记(75) - 元音辅音的辨读

  2. Python 字典(Dictionary) get()方法

    描述 Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值. 语法 get()方法语法: dict.get(key, default=None) 参数 ...

  3. MySQL与Oracle 差异比较之三函数

    函数 编号 类别 ORACLE MYSQL 注释 1 数字函数 round(1.23456,4) round(1.23456,4) 一样:ORACLE:select round(1.23456,4) ...

  4. 题目1003:A+B ---c_str(),atoi()函数的使用;remove , erase函数的使用

    #include<stdio.h> #include<stdlib.h> int sw(char *a){ ,c=; while(a[i]){ ') c=c*+a[i]-'; ...

  5. html --- ajax --- javascript --- 简单的封装

    Ajax的简单封装 Ajax的全称是AsynchronousJavaScriptAndXML 如有疑问请参考:http://zh.wikipedia.org/zh-cn/AJAX 以及传智播客的视频教 ...

  6. STL六大组件之——算法小小小小的解析

    参考自侯捷的<stl源码剖析> stl算法主要分为非可变序列算法(指不直接修改其所操作的容器内容的算法),可变序列算法(指可以修改它们所操作的容器内容的算法),排序算法(包括对序列进行排序 ...

  7. MATLAB 通过二进制读写文件

    这几天在做信息隐藏方面的应用,在读写文本文件时耗费许久,故特别的上网学习一二,这里给出一常用读写,其他的都类似. 很多时候,我们都要将一个.txt以二进制方式读出来,操作后在恢复成.txt文本. ma ...

  8. 通知(Toast+Notification)

    Toast简要说明:(前面已经用过好多次了) Toast是一种非持久的(在屏幕上面留一会儿就消失了),提供给用户简洁提示信息的视图. 它不阻断用户的操作,一般用于显示一些不重要的信息.(比方说设置音量 ...

  9. 使用ncc分析代码

    1 ncc是一个编译器, 用于输出程序的一些调用信息等, 可以查看函数调用关系, 支持函数指针, 查看数据结构和代码. 可以用来分析和理解代码. “" ... with ncc, in le ...

  10. [转]对Android开发者有益的40条优化建议

    下面是开始Android编程的好方法: 找一些与你想做事情类似的代码 调整它,尝试让它做你像做的事情 经历问题 使用StackOverflow解决问题 对每个你像添加的特征重复上述过程.这种方法能够激 ...