Android shares a simple and interesting animation effect

Source: Internet
Author: User

Android shares a simple and interesting animation effect

This article begins with sharing several simple and interesting animations.

:



The results are good, and the implementation is not very difficult.

Public int id [] = {R. drawable. fengjing_1, R. drawable. fengjing_2, R. drawable. fengjing_3, R. drawable. fengjing_4, R. drawable. fengjing_5, R. drawable. fengjing_6}; public String list [] = {"1", "2", "3", "4", "5", "6"}; private ListView mListView; private ImageView mImageView; protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); initView ();} private void initView () {mListView = (ListView) findViewById (R. id. list); ArrayAdapter
 
  
Adapter = new ArrayAdapter
  
   
(MainActivity. this, android. r. layout. simple_list_item_1, list); mListView. setAdapter (adapter); mListView. setOnItemClickListener (this); mImageView = (ImageView) findViewById (R. id. img); mImageView. setOnClickListener (this) ;}@ SuppressLint ("NewApi") private void animation (final int position) {final View vis; final View inVis; if (mListView. getVisibility () = View. VISIBLE) {vis = mListView; inVis = mImageView;} else {vis = mImageView; inVis = mListView;} ObjectAnimator objectAnimator = ObjectAnimator. ofFloat (vis, "RotationY", 0f, 90f); objectAnimator. setDuration (500); objectAnimator. start (); final ObjectAnimator objectAnimator2 = ObjectAnimator. ofFloat (inVis, "RotationY",-90f, 0f); objectAnimator2.setDuration (500); objectAnimator. addListener (new AnimatorListenerAdapter () {@ Overridepublic void onAnimationEnd (Animator animation) {super. onAnimationEnd (animation); objectAnimator2.start (); vis. setVisibility (View. GONE); mImageView. setImageResource (id [position]); inVis. setVisibility (View. VISIBLE) ;}}) ;}@ Overridepublic void onItemClick (AdapterView
   Arg0, View arg1, int arg2, long arg3) {animation (arg2) ;}@ Overridepublic void onClick (View arg0) {animation (0 );}
  
 

We mainly use Attribute animation, which will be detailed when I have more experiences with attribute animation .. This issue is purely about the effect of sharing...


Project source code



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.