Android thumb-up animation effect. add one or two methods after thumb-up, ① fill-in animation ② displacement Animation

Source: Internet
Author: User

Android thumb-up animation effect. add one or two methods after thumb-up, ① fill-in animation ② displacement Animation

First animation file btn_anim.xml

  
  
       
   
  

   

2-in the anim folder of the res folder, create the second file layout_anim.xml ):


  
      
   
  

3. I used the main activity in fragment.

...private ScrollView scrollView; // This is my container. Yours may be differentprivate Animation btnAnim;private Animation layoutAnim;...@Override    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {        // Getting context        context = getActivity().getApplicationContext();        btnAnim = AnimationUtils.loadAnimation(context, R.anim.btn_anim);        btnAnim.setAnimationListener(new Animation.AnimationListener() {            @Override            public void onAnimationStart(Animation animation) {            }            @Override            public void onAnimationEnd(Animation animation) {                layoutAnim = AnimationUtils.loadAnimation(context, R.anim.layout_anim);                scrollView.startAnimation(layoutAnim);            }            @Override            public void onAnimationRepeat(Animation animation) {            }        });        // create view        View view = inflater.inflate(R.layout.fragment_browse_single, container, false);        scrollView = (ScrollView) view.findViewById(R.id.scrollView);        myButton = (Button) view.findViewById(R.id.myButton);        myButton.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                btnZan.startAnimation(btnAnim);            }        });        Log.i(TAG, "View created");        return view;    }
Another demo method. Tried the thread. Not recommended

 
 
public class applaudAnimation extends Activity implements OnClickListener { private Button button; private TextView textView; private android.view.animation.Animation animation; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.animation); animation = AnimationUtils.loadAnimation(this,R.anim.applaud_animation); button = (Button) findViewById(R.id.bt); button.setOnClickListener(this); textView = (TextView) findViewById(R.id.animation); } @Override public void onClick(View v) { if (v == button) { textView.setVisibility(View.VISIBLE); textView.startAnimation(animation); new Handler().postDelayed(new Runnable() { public void run() { textView.setVisibility(View.GONE); } }, 1000); } }}

Animation. xml

"1.0" encoding="utf-8"?> "http://schemas.android.com/apk/res/android" android:layout_width= "fill_parent" android:layout_height= "fill_parent" android:background= "#ffffff" > android:id= "@+id/bt" android:layout_width= "40dip" android:layout_height= "wrap_content" android:layout_centerInParent= "true" android:gravity= "center" android:text= "Like" android:textColor= "#000000" android:textSize= "18dip" /> android:id= "@+id/animation" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:layout_centerInParent= "true" android:gravity= "center" android:text= "+1" android:textColor= "#FF0000" android:textSize= "18dip" android:visibility= "gone" />

  

applaud_animation.xml
"1.0" encoding="utf-8"?> "http://schemas.android.com/apk/res/android" > android:fromXDelta= "0" android:toXDelta= "0" android:fromYDelta= "0" android:toYDelta= "-50" android:duration= "1000" /> android:fromAlpha="1.0" android:toAlpha="0.3" android:duration="1000"/>

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.