Android ViewFlipper Animation

Source: Internet
Author: User

First, familiarize yourself with the four types of animations
Anim/push_up_in.xml. Enter Animation
[Html]
<Set xmlns: android = "http://schemas.android.com/apk/res/android">
<Translate android: fromYDelta = "100% p" android: toYDelta = "0" android: duration = "300"/>
<Alpha android: fromAlpha = "0.0" android: toAlpha = "1.0" android: duration = "300"/>
</Set>
Android: fromYDelta = "100% p" android: toYDelta = "0" percentage of views reached
FromAlpha = "0.0" transparency is 0, 1 is not transparent
Anim/push_up_out.xml. Exit Animation
[Html]
<Set xmlns: android = "http://schemas.android.com/apk/res/android">
<Translate android: fromYDelta = "0" android: toYDelta = "-100% p" android: duration = "300"/>
<Alpha android: fromAlpha = "1.0" android: toAlpha = "0.0" android: duration = "300"/>
</Set>

Anim/push_left_in.xml. Enter from the right
[Html]
<Set xmlns: android = "http://schemas.android.com/apk/res/android">
<Translate android: fromXDelta = "100% p" android: toXDelta = "0" android: duration = "300"/>
<Alpha android: fromAlpha = "0.0" android: toAlpha = "1.0" android: duration = "300"/>
</Set>

Anim/push_left_out.xml. Exit from left
[Html]
<Set xmlns: android = "http://schemas.android.com/apk/res/android">
<Translate android: fromXDelta = "0" android: toXDelta = "-100% p" android: duration = "300"/>
<Alpha android: fromAlpha = "1.0" android: toAlpha = "0.0" android: duration = "300"/>
</Set>

Add ViewFlipper to the main. xml file

[Html]
<ViewFlipper
Android: id = "@ + id/flipper"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: layout_marginBottom = "20dip"
Android: flipInterval = "2000">
 
<TextView
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: gravity = "center_horizontal"
Android: text = "@ string/animation_2_text_1"
Android: textSize = "26sp"/>
 
<TextView
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: gravity = "center_horizontal"
Android: text = "@ string/animation_2_text_2"
Android: textSize = "26sp"/>
 
<TextView
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: gravity = "center_horizontal"
Android: text = "@ string/animation_2_text_3"
Android: textSize = "26sp"/>
 
<TextView
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: gravity = "center_horizontal"
Android: text = "@ string/animation_2_text_4"
Android: textSize = "26sp"/>
</ViewFlipper>

// Set the animation www.2cto.com
MFlipper. setInAnimation (AnimationUtils. loadAnimation (this,
R. anim. push_up_in ));
// Set the exit Animation
MFlipper. setOutAnimation (AnimationUtils. loadAnimation (this,
R. anim. push_up_out ));
// Start the animation
MFlipper. startFlipping ();

At the same time, several animations slide_in_left.xml are also available in android. R. anim from the left. slide_out_right.xml
Author: Android_Xiaoqi

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.