zoukankan      html  css  js  c++  java
  • Android 模仿电视机关闭界面

    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 
    42 }
    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>

    源码下载

     

  • 相关阅读:
    PHP中cookie和会话编程
    PHPweb应用程序开发技巧
    javascript中DOM编程
    PHP动态创建Web站点
    在IE下FLASH背景透明而在FF下不透明的解决方法
    ThinkPHP返回插入记录的id号
    PHP面向对象编程
    PHP smarty编程总结
    Linux用户权限设置
    无法载入 mcrypt 扩展,请检查 PHP 配置
  • 原文地址:https://www.cnblogs.com/liangstudyhome/p/3950439.html
Copyright © 2011-2022 走看看