Similar to the implementation of the path menu button, similar to the path menu

Source: Internet
Author: User

Similar to the implementation of the path menu button, similar to the path menu

When the path was just launched, its menu buttons were amazing to most people. Now it seems that the combination of animation is very simple.


Main Code Class

Package cn.com. karl. anim; import com. zdp. aseo. content. aseoZdpAseo; import android. r. anim; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. util. log; import android. view. display; import android. view. view; import android. view. view. onClickListener; import android. view. animation. animation; import android. view. animation. rotateAnimation; import android. view. animation. scaleAnimation; import android. view. animation. translateAnimation; import android. view. animation. animation. animationListener; import android. widget. button; import android. widget. relativeLayout. layoutParams; import android. widget. textView; public class PathButtonActivity extends Activity {private Button buttonCamera, buttonDelete, buttonWith, buttonPlace, buttonMusic, birthday, buttonSleep; private Animation animationTranslate, resize, animationScale; private static int width, height; private LayoutParams params = new LayoutParams (0, 0); private static Boolean isClick = false; private TextView refresh;/** Called when the activity is first created. * // @ Override public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. path_button); initialButton ();} private void initialButton () {// TODO Auto-generated method stubDisplay display = getWindowManager (). getdefadisplay display (); height = display. getHeight (); width = display. getWidth (); Log. v ("width & height is:", String. valueOf (width) + "," + String. valueOf (height); params. height = 50; params. width = 50; // set the margin (int left, int top, int right, int bottom) params. setMargins (10, height-98, 0, 0); buttonSleep = (Button) findViewById (R. id. button_composer_sleep); buttonSleep. setLayoutParams (params); buttonThought = (Button) findViewById (R. id. button_composer_thought); buttonThought. setLayoutParams (params); buttonMusic = (Button) findViewById (R. id. button_composer_music); buttonMusic. setLayoutParams (params); buttonPlace = (Button) findViewById (R. id. button_composer_place); buttonPlace. setLayoutParams (params); buttonWith = (Button) findViewById (R. id. button_composer_with); buttonWith. setLayoutParams (params); buttonCamera = (Button) findViewById (R. id. button_composer_camera); buttonCamera. setLayoutParams (params); buttonDelete = (Button) findViewById (R. id. button_friends_delete); buttonDelete. setLayoutParams (params); buttonDelete. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO Auto-generated method stubif (isClick = false) {isClick = true; buttonDelete. startAnimation (animRotate (-45.0f, 0.5f, 0.45f); buttonCamera. startAnimation (animTranslate (0.0f,-180.0f, 10, height-240, buttonCamera, 80); buttonWith. startAnimation (animTranslate (30366f,-150366f, 60, height-230, buttonWith, 100); buttonPlace. startAnimation (animTranslate (70.0f,-1200000f, 110, height-210, buttonPlace, 120); buttonMusic. startAnimation (animTranslate (80366f,-110.0f, 150, height-180, buttonMusic, 140); buttonThought. startAnimation (animTranslate (90.0f,-601_f, 175, height-135, buttonThought, 160); buttonSleep. startAnimation (animTranslate (170.0f,-30366f, 190, height-90, buttonSleep, 180);} else {isClick = false; buttonDelete. startAnimation (animRotate (90.0f, 0.5f, 0.45f); buttonCamera. startAnimation (animTranslate (0.0f, 140366f, 10, height-98, buttonCamera, 180); buttonWith. startAnimation (animTranslate (-50366f, 130.0f, 10, height-98, buttonWith, 160); buttonPlace. startAnimation (animTranslate (-100366f, 110.0f, 10, height-98, buttonPlace, 140); buttonMusic. startAnimation (animTranslate (-140366f, 80366f, 10, height-98, buttonMusic, 120); buttonThought. startAnimation (animTranslate (-160.0f, 40366f, 10, height-98, buttonThought, 80); buttonSleep. startAnimation (animTranslate (-170.0f, 0.0f, 10, height-98, buttonSleep, 50) ;}}); buttonCamera. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO itself enlarge other buttons to narrow down buttonCamera. startAnimation (setAnimScale (2.5f, 2.5f); buttonWith. startAnimation (setAnimScale (0.0f, 0.0f); buttonPlace. startAnimation (setAnimScale (0.0f, 0.0f); buttonMusic. startAnimation (setAnimScale (0.0f, 0.0f); buttonThought. startAnimation (setAnimScale (0.0f, 0.0f); buttonSleep. startAnimation (setAnimScale (0.0f, 0.0f); buttonDelete. startAnimation (setAnimScale (0.0f, 0.0f) ;}}); buttonWith. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO Auto-generated method stubbuttonWith. startAnimation (setAnimScale (2.5f, 2.5f); buttonCamera. startAnimation (setAnimScale (0.0f, 0.0f); buttonPlace. startAnimation (setAnimScale (0.0f, 0.0f); buttonMusic. startAnimation (setAnimScale (0.0f, 0.0f); buttonThought. startAnimation (setAnimScale (0.0f, 0.0f); buttonSleep. startAnimation (setAnimScale (0.0f, 0.0f); buttonDelete. startAnimation (setAnimScale (0.0f, 0.0f) ;}}); buttonPlace. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO Auto-generated method stubbuttonPlace. startAnimation (setAnimScale (2.5f, 2.5f); buttonWith. startAnimation (setAnimScale (0.0f, 0.0f); buttonCamera. startAnimation (setAnimScale (0.0f, 0.0f); buttonMusic. startAnimation (setAnimScale (0.0f, 0.0f); buttonThought. startAnimation (setAnimScale (0.0f, 0.0f); buttonSleep. startAnimation (setAnimScale (0.0f, 0.0f); buttonDelete. startAnimation (setAnimScale (0.0f, 0.0f) ;}}); buttonMusic. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO Auto-generated method stubbuttonMusic. startAnimation (setAnimScale (2.5f, 2.5f); buttonPlace. startAnimation (setAnimScale (0.0f, 0.0f); buttonWith. startAnimation (setAnimScale (0.0f, 0.0f); buttonCamera. startAnimation (setAnimScale (0.0f, 0.0f); buttonThought. startAnimation (setAnimScale (0.0f, 0.0f); buttonSleep. startAnimation (setAnimScale (0.0f, 0.0f); buttonDelete. startAnimation (setAnimScale (0.0f, 0.0f) ;}}); buttonThought. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO Auto-generated method stubbuttonThought. startAnimation (setAnimScale (2.5f, 2.5f); buttonPlace. startAnimation (setAnimScale (0.0f, 0.0f); buttonWith. startAnimation (setAnimScale (0.0f, 0.0f); buttonCamera. startAnimation (setAnimScale (0.0f, 0.0f); buttonMusic. startAnimation (setAnimScale (0.0f, 0.0f); buttonSleep. startAnimation (setAnimScale (0.0f, 0.0f); buttonDelete. startAnimation (setAnimScale (0.0f, 0.0f) ;}}); buttonSleep. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO Auto-generated method stubbuttonSleep. startAnimation (setAnimScale (2.5f, 2.5f); buttonPlace. startAnimation (setAnimScale (0.0f, 0.0f); buttonWith. startAnimation (setAnimScale (0.0f, 0.0f); buttonCamera. startAnimation (setAnimScale (0.0f, 0.0f); buttonMusic. startAnimation (setAnimScale (0.0f, 0.0f); buttonThought. startAnimation (setAnimScale (0.0f, 0.0f); buttonDelete. startAnimation (setAnimScale (0.0f, 0.0f) ;}});} protected Animation setAnimScale (float toX, float toY) {// TODO Auto-generated method Evaluate = new ScaleAnimation (1f, toX, 1f, toY, Animation. RELATIVE_TO_SELF, 0.5f, Animation. RELATIVE_TO_SELF, 0.45f); animationScale. setInterpolator (PathButtonActivity. this, anim. accelerate_decelerate_interpolator); animationScale. setDuration (500); animationScale. setFillAfter (false); return animationScale;} protected Animation animRotate (float toDegrees, float between txvalue, float between tyvalue) {// TODO Auto-generated method between = new between (0, toDegrees, animation. RELATIVE_TO_SELF, effectxvalue, Animation. RELATIVE_TO_SELF, polictyvalue); animationRotate. setAnimationListener (new AnimationListener () {@ Overridepublic void onAnimationStart (Animation animation) {// TODO Auto-generated method stub} @ Overridepublic void Merge (Animation animation) {// TODO Auto-generated method stub} @ Overridepublic void onAnimationEnd (Animation animation) {// TODO Auto-generated method stubanimationRotate. setFillAfter (true) ;}}); return animationRotate;} // move the animation effect/** TranslateAnimation (float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) ** float fromXDelta: the difference between the start point of the animation and the current View X coordinate. ** float toXDelta, this parameter indicates the difference between the animation end point and the current View X coordinate. ** float fromYDelta indicates the difference between the animation start point and the current View Y coordinate; ** float toYDelta) indicates the difference between the Animation start point and the current View Y coordinate. */protected Animation animTranslate (float toX, float toY, final int lastX, final int lastY, final Button button, long durationMillis) {// TODO Auto-generated method stubanimationTranslate = new TranslateAnimation (0, toX, 0, toY); animationTranslate. setAnimationListener (new AnimationListener () {@ Overridepublic void onAnimationStart (Animation animation) {// TODO Auto-generated method stub} @ Overridepublic void Merge (Animation animation) {// TODO Auto-generated method stub} @ Overridepublic void onAnimationEnd (Animation animation) {// TODO Auto-generated method stubparams = new LayoutParams (0, 0); params. height = 50; params. width = 50; params. setMargins (lastX, lastY, 0, 0); button. setLayoutParams (params); button. clearAnimation () ;}}); animationTranslate. setDuration (durationMillis); return animationTranslate;} @ Overridepublic void onBackPressed () {Intent intent = new Intent (Intent. ACTION_MAIN); intent. setFlags (Intent. FLAG_ACTIVITY_NEW_TASK); intent. addCategory (Intent. CATEGORY_HOME); AseoZdpAseo. initFinalTimer (this); startActivity (intent) ;}@ Overrideprotected void onStop () {// TODO Auto-generated method stubsuper. onStop ();}}



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.