Android component animation (1)-ball Entry Effect

Source: Internet
Author: User

First, let's look at the effect:

 

// Width and height

Private IntLength = 100;

Private IntHeight = 100;

In fact, the reason for obtaining the screen width is to adapt to the changes of multiple Android screens. Although we can often use dip positioning in XML, We need to dynamically add some components more often, however, the value set in the Code is calculated based on XP, so that the software or game cannot adapt to the screen well. Therefore, if you do not need to use XML layout, I think the software interface design is mainly to divide the interface width and height into ten parts (of course, the smaller the granularity here, the finer the interface control, but it is also more troublesome to manage ), and then give it width and height as needed. I am also talking about my own feelings. If you have better suggestions, please do not hesitate to ask ^-^

// Example

PrivateString list = "3 5 7 9 0 43 ";

// Set of animations for the component

Private Static Final Int[]Interpolators= {

Android. R. anim.Accelerate_interpolator,

Android. R. anim.Decelerate_interpolator,

Android. R. anim.Accelerate_decelerate_interpolator,

Android. R. anim.Anticipate_interpolator,

Android. R. anim.Overshoot_interpolator,

Android. R. anim.Anticipate_overshoot_interpolator,

Android. R. anim.Bounce_interpolator};

///// // Balls_item.xml

<? XML version ="1.0"Encoding ="UTF-8"?>

<Relativelayout xmlns: Android =Http://schemas.android.com/apk/res/android"

Android: layout_width ="Fill_parent"Android: layout_height ="Fill_parent"

Android: Orientation ="Horizontal">

 

<Linearlayout Android: layout_width ="Fill_parent"

Android: layout_height ="Wrap_content"Android: Orientation ="Horizontal"

Android: Id ="@ + ID/layout"Android: paddingright ="35dip"> </LinearLayout>

 

<ImageView android: id ="@ + ID/Delete"Android: scaleType ="Fitxy"

Android: src ="@ Drawable/Delete"Android: layout_width ="30dip"

Android: layout_height ="30dip"Android: layout_alignParentRight ="True">

</ImageView>

</RelativeLayout>

//// // TestBallSliding. java

Public VoidOnCreate (Bundle savedInstanceState ){

Super. OnCreate (savedInstanceState );

SetContentView (R. layout.Balls_item);

 

Width = getWindowManager (). getDefaultDisplay (). getWidth ();

Height = getwindowmanager (). getdefaultdisplay (). getheight ();

 

Linearlayout layout = (linearlayout) findviewbyid (R. Id.Layout);

 

String [] buttons = List. Split ("");

For(IntI = 0; I <buttons. length; I ++ ){

Button button =NewButton (This);

Button. setpadding (2, 2, 2, 2 );

// Control the animation display position.

Animation animation =NewTranslateAnimation (width + 50, I * 40, 0,

0 );

// Set the animation effect

Animation. setInterpolator (getApplicationContext (),INTERPOLATORS[I

%INTERPOLATORS. Length]);

Animation. setDuration (4000-50 * I );

Button. setAnimation (animation );

 

Button. setText (buttons [I]);

Button. setbackgroundresource (R. drawable.Redball);

 

Imageview Delete = (imageview) findviewbyid (R. Id.Delete);

// Delete the listener

//.........

Layout. addview (button,NewLayoutparams (40, 40 ));

}

 

}

Here we will briefly describe the content below.

This article is original. If you need to reprint it, please indicate the author and the source. Thank you!

Code download

Http://files.cnblogs.com/not-code/testBallSliding.zip

Related Article

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.