A code-sharing _android with a large floating effect on the selected icon in Android apps

Source: Internet
Author: User

Recently in playing 3g sports portal client, see this effect: Touch the game icon, there will be an icon to the effect of a large surface. It's kind of interesting. So I made a copy of it.
This is the original artwork:

is actually adding a scaled animation to the icon's touch event, the code is as follows.

Package com.test; 
Import android.app.Activity; 
Import Android.os.Bundle; 
Import android.view.MotionEvent; 
Import Android.view.View; 
Import Android.view.View.OnTouchListener; 
Import android.view.animation.Animation; 
Import android.view.animation.ScaleAnimation; 
 
Import Android.widget.Button; 
    public class Animationbuttonactivity extends activity {@Override public void onCreate (Bundle savedinstancestate) { 
    Super.oncreate (savedinstancestate); 
    Setcontentview (R.layout.main); 
     
     
Final Button test = (Button) Findviewbyid (R.ID.TEST_BT); 
float f1 = 1.0F; 
float F2 = 1.3F; 
int j = 1; 
     
    float F3 = 0.5F; Parameter description://float FromX animation at the beginning of the expansion of the x-coordinate size//float ToX animation at the end of the x-coordinate scaling size//float FromY animation at the start of the y-coordinate scale dimension//flo At the end of the at ToY animation, the scaling dimension on the y-coordinate//int pivotxtype animation at the x axis relative to the object position type//float Pivotxvalue the start position of the x-coordinate of the animation relative to the object//int ype animation in the y-axis relative to the object position type//float Pivotyvalue the start position of the animation relative to the y-coordinate of the object finalImation logoanimation = new Scaleanimation (1.0F, 1.3F, 1.0F, 1.3F, 1, 0.5F, 1, 0.5F); 
     
    Set the animation interval logoanimation.setduration (100L);  Test.setontouchlistener (New Ontouchlistener () {@Override public boolean ontouch (View V, motionevent 
        Event) {//Start animation test.startanimation (logoanimation); 
      return false; 
  } 
    });  } 
}

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.