Android Multiple Views - android

I am trying to make an app that will have multiple screens, and I want to be able to swipe left and right to go back and forth from screen to screen. Basically like how you go through pi ctures in the gallery, but mine won't just be pictures. Any tutorials or a suggestion on what type layout I should use.. TIA

Try HorizontalScrollView. If you want it to snap, you will probably have to write some code that sets the position of the scrollview correctly either on up touchevents, and/or intercepting those events to a GestureDetector with SimpleOnGestureListener to catch flings specifically.

You can have this effect using ViewFlipper...
http://www.warriorpoint.com/blog/2009/05/26/android-switching-screens-in-an-activity-with-animations-using-viewflipper/

You need to apply gestures. This link could help you which explains the same you need:
http://www.anddev.org/view-layout-resource-problems-f27/swipe-fling-to-switch-between-activities-t15602.html

You can try using a Gallery View with an adapter that returns the views you want to scroll with. But it's going to be a pain laying out the views...

You can do something like the launch screen has.
http://blog.velir.com/index.php/2010/11/17/android-snapping-horizontal-scroll/
also:
Flingable Tab Host
also:
Android Snapping HorizontalScrollView
and finally:
Horizontal Pager

Related

Android: I want to swipe between cells of a grid where only one cell is visible at a time

I want a single cell of a grid to take up my whole screen and swipe up/down/left/right to access other cells (not smoothly, but switch to the next cell). What do you think is a good way of implementing this?
I've partially implemented this in GridView and ListView containing a HorizontalListView and am considering TableLayout.
Any advice?
I would start with the DirectionalViewPager on github and try to modify it so that it can always swipe in any direction instead of having to call setOrientation(DirectionalViewPager.VERTICAL)and setOrientation(DirectionalViewPager.HORIZONTAL) I don't know exactly how much you'll have to modify it, but it is most of the way there, I would think that the change should be relatively straight forward.
How about you take a look at this. the horizontal paging(swipe views)

How to use Android HorizontalScrollView to move image one by one

I want to create an image slider using the HorizontalScrollView. Indeed, the slider will display one image at the time and I want to be able to use the fling gesture to navigate left and right in the slider.
Any Idea to which methods to override in the HorizontalScrollView to achieve this.
Thanks a lot.
Best
You could use Gallery with Image Switcher view to achieve this
This Link is usefull to you for better way to implement Android HorizontalScrollView to move image one by one.
Link :http://saigeethamn.blogspot.in/2010/05/image-switcher-view-android-developer.html
video: http://www.youtube.com/watch?v=c6a6wTfSPJA
EDIT :
If you want to implement Complex way refer this Links
Link1
Link2
You'd be better served implementing this with a Gallery widget or a ViewPager. These elements handle the display and interaction portion for you; you just have to provide the data behind that. If these don't quite work for you, better to customize one of them then start all the way from scratch.
Gallery Docs
ViewPager Docs
You can use any of below things for your need
Gallery - A view that shows items in a center-locked, horizontally scrolling list.
ViewPager -Layout manager that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter to generate the pages that the view
shows.
HorizontalScrollView -Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display
for reference see these links - Gallery , ViewPager and HorizontalScrollView

Extending viewpager to include navigation indicators

I'm trying to add some arrows to the screen to indicate if there are items available to the left or right so that the user knows to scroll.
Initially I just added these images into the instantiateItem function in the pageradapter. However I want to animate the arrows so that they fade in and out and disappear when the user touches the screen.
I've started to think that I may be best off extending the viewpager class so that it always displays the arrows independently of the adapter. I've looked through the code but can't see a place where I would add the overlay view.
Has anyone got any ideas?
Thanks,
m
As suggested by CommonsWare
You might wish to take a look at github.com/JakeWharton/Android-ViewPagerIndicator and see how Jake did it.
this information lead me to the solution.

PopupWindow with swiping scrollable views

I'm trying to create a Popupindow in which the views can be changed by swiping. Each view should also be scrollable when larger than the popup window. I also want to move only one view when swiping. I can't find any simple way to do that (the Gallery move several views when swiping).
Is there any widget I missed or do I have to implement everything to achieve that (with ViewFlipper and gesture detection for instance)?
Anybody can help with the best way to do that?
Thanks
I've found and ended up using the fantastic HorizontalPager.

Android: Next/Previous fling that sticks to the finger similar to Home Screen

I want to give my app a nice touch by allowing users to slide the page left or right instead of just using next/previous buttons (similar to the home screen).
What is the best way to do that? I assume I would have to override one of the Activity.on... methods and that I would also have to put my page's main View in a ViewGroup that allows me to shift pages left and right.
ViewFlipper is your friend!
Here you can see a nice video of the ViewFlipper in action and also a very good tutorial:
http://www.inter-fuser.com/2009/07/android-transistions-slide-in-and-slide.html
The solution is even easier these days with the release of Compatibility Package r3. You can download here: http://developer.android.com/sdk/compatibility-library.html
It includes
ViewPager: A ViewGroup that manages the layout for the child views, which the user can swipe between.
PagerAdapter: An adapter that populates the ViewPager with the views that represent each page.
and Fragment versions of those, if you are that way inclined.
The pager code is compatible back to API version 4 (1.6), and I just implemented a dynamically generated viewPager coming off a dynamically generated ListView in about 2 hours. I'm a novice, so this is definitely the preferred path.
There is an example app here: http://geekyouup.blogspot.com/2011/07/viewpager-example-from-paug.html
If one wants to flip between two activities perhaps one can apply this animated transition:
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(intent);
finish();
//transition using XML view animations
overridePendingTransition(R.anim.slideinfromright, R.anim.slideouttoleft);
Use GestureDetector to detect if the touch event is a scroll.
If the first event to the first call to onScroll is ACTION_DOWN then you should see if it was a dominantly horizontal scroll. If so then your scroll is started and you should shift the absolute position of the view that fills the page.
For non deprecated absolute positioning, see my answer here Android: Alternative to AbsoluteLayout (I really do need absolute positioning)
You will want to be cautions of whether you return true to consume the touch events or not.
GestureDetector does not have a callback for scrolling having stopped. You will have to check if there was an ACTION_UP before you call GestureDetector.onTouchEvent and if there was an action up and you did have an unfinished scroll then you should set the absolute position to the destination location and use a TranslateAnimation to make it look nice moving from current to destination.
Edit:
GestureDetector did not work well at all if the child views also wanted to respond to touch events. I ended up creating a subclass of FrameLayout (one of the most basic layouts and the closest thing to a non intrusive parent view) and overriding dispatchTouchEvent. I just took all the events and did the detection myself.
cant we use Gallery view here?? with the adapter the whole page can be inflated inside gallery view adapter getView() and it will manage the left right scrolling perfectly.

Categories

Resources