homescreen - Android Home Screen effect -
I want to do something like an Android home screen effect. When I click on the screen and move the current view will move forward and the next scene can also be shown.
Now the code can only show the current view.
Thank you for your help
Follow the form of the source:
Public class test activity enhances tools OnTouchListener {float downXValue; /** Called when the activity is first created. * / @ Override Crate on Public Zero (Bundle Saved Instantstate) {Super. Contents (Saved Instantstate); // Set.XML as the layout for this activity set Content View (R. Layout.man); // Add these two lines LinearLayout layMain = (LinearLayout) findViewById (R.id.layout_main); LayMain.setOnTouchListener (OnTouchListener this); // Spinner Spinner Spinner: Add countries to some countries = (Spinner) Find VViBiID (RID SpinnerCountry); ArrayAdapter CountryArrayator = New Arrayadapter (this, android.R.layout.simple_spinner_dropdown_item, New string [] {"Canada", "USA"}; spinnerCountries.setAdapter (countryArrayAdapter);} Public Boolean On-Touch (see Arg 0, Motion Avenger 1) {// This Touch Event Switch (ARG 1.Attaction ()) Take action on {Case MotionEvent.ACTION_DOWN: {// Store X When the user has a finger pressed down, XValue = arg1.getX (); breakage;} case MotionEvent.ACTION_UP: {// Get the X value when the user has released his finger float currentX = arg1.getX ( ); // Moving backwards: Pushing the right to the right (Get XValue currentX) {// ViewById (R.id.details); // animation vf.setInAnimation (AnimationUtils.loadAnimation (set it, R.anim.push_left_in); // flip! Vf.showNext (); } break; } Case MotionEvent.ACTION_MOVE: VisualFlipper vf = (ViewFlipper) findViewById (R.id.details); Last view currentView = vf.getCurrentView (); CurrentView.layout ((int (arg1.getX () - downExValue), current view. GateTap (), current view. Gatrite (), current view. Buttbottom ()); / * Thest * / break can do something; } // If you return false, then these actions can not be recorded; }}
You can use Viewpager
. Tofiq Ahmed says:
The best way to switch between the viewpages view is the best way. It provides a way to swipe from left to right and from left to right view Viewpager provides a solid way of swiping any view
You have to expand the pager adapter
and then use the Viewpager
. You can see the snippet and full source code
Comments
Post a Comment