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