Simulates the exit Effect of Youku like Guan TV

Source: Internet
Author: User

In fact, the exit effect like watching TV is just an animation. You can think about it first. The idea is actually very simple.

1. Instant white screen is required.

2. The white screen is squashed in the middle with uniform acceleration or even deceleration until a white line disappears, and the whole process is about 200 milliseconds.

3. Black Background exposed.

First, write the layout file. There are many other options. The simplest one is to use RelativeLayout or FrameLayout as the root layout of the application's first interface. If the background color of the application is black, it is best, just like Youku. If the background color of the application is not black, write one in the root layout:

 
 
  1. <FrameLayout 
  2.       android:id="@+id/fl_off" 
  3.         android:layout_width="fill_parent" 
  4.         android:layout_height="fill_parent" 
  5.         android:visibility="gone" 
  6.          > 
  7.     <ImageView 
  8.         android:layout_width="fill_parent" 
  9.         android:layout_height="fill_parent" 
  10.         android:background="@color/text_black" /> 
  11.     <ImageView 
  12.           android:id="@+id/iv_off" 
  13.         android:layout_width="fill_parent" 
  14.         android:layout_height="fill_parent" 
  15.         android:background="@color/text_white"  
  16.          android:visibility="gone"/> 
  17. </FrameLayout> 

The first ImageView is a black background color, and the second is a white background color.

The following is the syntax of the animation file res/anim/TV _off.xml:

 
 
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <set android:shareInterpolator="false" 
  3. android:zAdjustment="top" 
  4.   xmlns:android="http://schemas.android.com/apk/res/android">
  5. <span></span> 
  6. <scale android:interpolator="@android:anim/accelerate_interpolator" 
  7. android:duration="200" 
  8. android:pivotX="50.0%" 
  9. android:pivotY="50.0%" 
  10. android:fromXScale="1.0" 
  11. android:toXScale="1.0" 
  12. android:fromYScale="1.0" 
  13. android:toYScale="0.0030" /> 
  14.     <scale android:interpolator="@android:anim/accelerate_interpolator" 
  15. android:duration="200" 
  16. android:pivotX="50.0%" 
  17. android:pivotY="50.0%" 
  18. android:startOffset="200" 
  19. android:fromXScale="1.0" 
  20. android:toXScale="0.0" 
  21. android:fromYScale="1.0" 
  22. android:toYScale="0.3" /> 
  23.     <alpha android:interpolator="@interpolator/accelerate_quint" 
  24. android:duration="400" 
  25. android:fillAfter="true" 
  26. android:fromAlpha="1.0" 
  27. android:toAlpha="0.0" 
  28. android:fillEnabled="true" /> 
  29. </set> 

This is simple, just copy it.

Because the animation is referenced to the accelerator, the following is the method of writing the accelerator file res/interpolator/accelerate_quint.xml:

 
 
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <accelerateInterpolator android:factor="2.5" 
  3.   xmlns:android="http://schemas.android.com/apk/res/android" /> 

This is a uniform acceleration accelerator, with a acceleration multiple of 2.5.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.