I am new to Android. Here, I want to implement Swipe Gesture to navigate between Activities. I have googled it and found different answers in different sites. But I could not get the exact point.
By reading all of them I got that we need to implement onTouchEvent() and onFlingEvent().
Are these functions enough to implement the Swipe action?
Please specify on How to proceed step wise to implement swipe gesture.
I am sorry if I asked you a very simple question as I have asked this question after a long long try of many code snippets.
Can any one please clear my doubt?
onTouchEvent is enough. What you want to do is:
Create a VelocityTracker and feed it the
touch results from the view.
When you get a UP event, check what the velocity was. If its more
than some threshold amount in the X direction, that counts as a
swipe.
Start a new activity when you recognize it.
You'll likely have to play with the threshold a bit, otherwise a sloppy tap could be mistaken for a swipe.
If you want to swipe your view then you should use ViewFlipper You can set a onTouchListener on ViewFlipper. And you can register GestureDetector in onTouchListener. Here is one good example for that Android transitions- slide in and slide out.
Related
I'm trying to create an overlay that is triggered when a button is pressed. This overlay is supposed to allow the user to add their contact and I was wondering how can I use fragments to get this effect like you can see in this mockup.
I am in a dilemna over using fragments is the right choice. My reasoning being that I only need to have it do one task that is adding contacts, and thus I do not need a whole activity.
This is what I have on the main activity right now
I would really appreciate any help on understanding how to make this work.
You can use a DialogFragment.
It behaves like a normal Fragment for the most part. Here is a guide for a basic implementation https://guides.codepath.com/android/using-dialogfragment
They appear automatically in the center of the screen. To get it a bit lower like in your mockup you can change where it is in the window. Here is an answer showing such Position of DialogFragment in Android
i'm developing an application for android that is already done for IOS, is not big problem.
the thing is that my boss want it to be exactly the same, but one of the menus is the problem, is like a slide menu but with zoom and a background image, anyone have any idea how can i do this, i already google it but no results :(, a library would help.
here is a picture with the menu for IOS.
I don't think if it would be an effective solution but you can use a RelativeLayout.
Put the selection part behind in a LinearLayout then put a framelayout front to contain list fragments. This way you shouldn't use an action bar to have absolutely same looking with iOs version.
When someone clicks open button apply an animation to your framelayout. scale it by %75 and move it 25% in y coordinate and move it %50 in x coordinate. When buttons in your LinearLayout apply a reverse animation to your FrameLayout. If swap button clicked change your fragment with new one. You can also aply a transaction animation to your fragments.
I hope you know how to handle this stuff. If no I can do my best to code an example.
EDIT:
Don't forget to set your flame layout unclickable when you move it to right side.
https://github.com/SpecialCyCi/AndroidResideMenu
I think I found your answer. I came across this in a list of libraries it is 3.8 on the list https://github.com/Trinea/android-open-project/tree/master/English%20Version
Cheers!
I think this could be a bit difficult.
I created an coordinate system, to build a game upon it. Since now your are able to move left and right by swiping. Is it possible to allow swipe up/down?
But I think its very annoying to swipe all the time, so I had the idea to add a system like google maps using it (move around by tap and hold).
Is there already a listener or something similar to include this, or does anybody know how to create something like that.
I've already searched around the web to find something... without success.
Thanks for your help.
I've got an awnser myself, just use the OnTouchListener and catch the MotionEvent.ACTION_DOWN and .ACTION_MOVE for example so you are able to always get the current touch position and calculate the difference between it and the start position and animate the map for this values.
Android has many useful tools when coming to views and screens and layouts.
Description: While playing my game (running around as a zombie bear eating humans) I would like to allow the player to access an items menu via sliding a menu from the right side/edge of the screen. Or at the least be able to access a game options menu (not game settings which would be the menu button).
What would be the best fit for description?
P.S How would I make a question like this less like a discussion and more like a straight forward programming question when I don't really know what's available to do this.
Also, if this is the case, please point me to another location to ask a question that may require a discussion.
Thank You!
Try looking at the SlidingDrawer class.
PS I personally don't see a problem with how you have worded your question if you are looking for ideas of views/widgets you need to perform a specific function/effect.
My first thought, and for a simple approach (this wouldn't be animated or dragged really), would be using a RelativeLayout where the portion representing the menu was initially set so that it's visibility were GONE, except for a small tab or arrow or something. When that tab/arrow is touched, the visibility of the View for the menu could be toggled to VISIBLE.
With visibility set to GONE, a view is not drawn or considered in any part of the layout pass when the screen is drawn.
You could populate a listview with some icons and when an particular icon is selected, then figure out which one was selected and then execute some function and hide the sidebar using an animation. I've never developed a game, so I'm not too sure how far it deviates from the standard, but I wish you the best of luck :) ! If you post the source let me know would love to test your game and see how you work with the source!
at the moment i'm trying to write an app which has a listview, and if i swipe especially left the listitem switches to another xml like it's used in the twitter app.
Especially i have a list of items only with some text and when i swipe left on a single item it changes to an other item (via a xml-file) especially with some buttons or anything else.
I hope anyone, has an idea how i can do this?
Thanks.
I have seen this done using a Gallery set to fill_parent. Care has to be taken to allow child views to pass on touch events appropriately for swiping to work. Note that Gallery is a subclass of ViewGroup.
EDIT: see comment below, i should've checked the twitter app first!