We all know that the beautiful app will always give users a refreshing feeling, in order to seize the user more large network companies to make their products more gorgeous, and the most simple effect is the activity jump effect, not only can make users look comfortable, but also to achieve a particularly simple, good, Below let us achieve these effects, farewell to the original ecological jump effect it!
Start with a new Android project called Androidswitch. Really do not know what name, there is a name, first let us look at the XML code is very simple, a ListView code is as follows:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"Android:layout_width="fill_parent"Android:layout_height="fill_parent"android:orientation="Vertical"> <ListView Android:id="@+id/listview1"Android:layout_width="match_parent"Android:layout_height="wrap_content"> </ListView></LinearLayout>
The ListView in this XML is mainly responsible for some effects of the Click event, display the effect of the text I will be placed in the values, together with the project to you! Jump effect. The most important of course is animation. No animation to talk about the effect, So we create a new Anim file in the res file for a variety of animations, animations quite a lot of, I would like to give a simple XML. I will give you the project, I can see it for myself! The following:
<?xml version="1.0"encoding="Utf-8"?><SetXmlns:android="http://schemas.android.com/apk/res/android"> <Translate android:duration=" -"Android:fromxdelta="0"Android:toxdelta="-100%p"/></Set>
is not very simple, good, unexpectedly animation also edited, we need to where to call it. Yes, we also need a jump secondactivity, in this secondactivity I only put a button to return, so do not press the back key so troublesome, It works just to show the effect of the first activity jump, let me see. As shown below:
Package Com.zqy.androidswitch;import android.app.activity;import android.os.bundle;import Android.view.View; Import Android.view.view.onclicklistener;import Android.widget.Button; Public classsecondactivity extends activity{@Overrideprotected voidonCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.act_second); Final button button=(Button) Findviewbyid (R.id.button1); Button.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {finish (); } }); }}
Well, basically half done, I need to write the code of implementation, this is the core, let's see how the core code is implemented: the following:
Package Com.zqy.androidswitch;import Java.util.arraylist;import java.util.list;import android.os.Bundle;import Android.app.activity;import Android.content.intent;import Android.view.view;import Android.widget.AdapterView; Import Android.widget.arrayadapter;import Android.widget.listview;import Android.widget.AdapterView.OnItemClickListener; Public classMainactivity extends Activity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Final ListView ListView=(ListView) Findviewbyid (R.ID.LISTVIEW1); string[] LS=getresources (). Getstringarray (R.array.anim_type); List<String> list =NewArraylist<string>(); for(inti =0; i < ls.length; i++) {List.add (ls[i]); } arrayadapter<String> adapter =NewArrayadapter<string> ( This, Android. R.layout.simple_list_item_1, list); Adapter.setdropdownviewresource (Android. R.layout.simple_list_item_1); Listview.setadapter (adapter); Listview.setonitemclicklistener (NewOnitemclicklistener () {@Override Public voidOnitemclick (adapterview<?>Parent, view view,intPositionLongID) {Intent Intent=NewIntent (mainactivity. This, Secondactivity.class); StartActivity (Intent); Switch(position) { Case 0: Overridependingtransition (R.anim.fade, r.anim.hold); Break; Case 1: Overridependingtransition (R.anim.my_scale_action, r.anim.my_alpha_action); Break; Case 2: Overridependingtransition (R.anim.scale_rotate, r.anim.my_alpha_action); Break; Case 3: Overridependingtransition (R.anim.scale_translate_rotate, r.anim.my_alpha_action); Break; Case 4: Overridependingtransition (R.anim.scale_translate, r.anim.my_alpha_action); Break; Case 5: Overridependingtransition (r.anim.hyperspace_in, r.anim.hyperspace_out); Break; Case 6: Overridependingtransition (r.anim.push_left_in, r.anim.push_left_out); Break; Case 7: Overridependingtransition (r.anim.push_up_in, r.anim.push_up_out); Break; Case 8: Overridependingtransition (R.anim.slide_left, r.anim.slide_right); Break; Case 9: Overridependingtransition (R.anim.wave_scale, r.anim.my_alpha_action); Break; Case Ten: Overridependingtransition (R.anim.zoom_enter, r.anim.zoom_exit); Break; Case One: Overridependingtransition (r.anim.slide_up_in, r.anim.slide_down_out); Break; default: Break; } } }); } }
Using the ListView to dress up the various effects of the Click event, we clicked on the ListView to perform what kind of animation according to the click position. I don't know how to make GIF pictures on my phone, I'll show you the main page, we can download the demo.
Well, the basic implementation is over. It's very simple. With these animations, you will be able to make your app a beautiful scenery line, you can directly get the project inside with Oh! The last sentence, the big God do not spray, suitable for beginners!
SOURCE download, please click here
Android activity jump to turn the painting, let your app instantly gorgeous up