I am developing an app in which I need to implement object movement following by users finger touch/drag. My object is at the bottom of the screen and it can move horizontal only. I have no idea about Gesture control or Object movement in Android.
Also, the object should maintain its state, for example if user stops dragging the object it should appear to its last position only.
I need to sort this out, any help would be appreciable.
Thanks
are you looking for this:
https://www.youtube.com/watch?v=hdxdTkdNkVs
than have a look on this:
https://github.com/fouady/SpotifyTray-Android
Related
I want to implement touch listener that detects
Click/tap on chess piece in order to select ot
Swipe/move of chess piece immediately.
How to do it?
Unfortunately, I am not sure what you mean by a "chess piece", but let's assume that the board is a view in the background, and inside you have inner views which are chess pieces.
To achieve the select/unselect given piece effect you should add a simple View.OnClickListener interface to your view. Each of your pieces should have a view class and some data connected to it (like a position, a type of piece, id, etc.). After clicking the piece update the state of some global variable, for example, selectedPiece with an ID assigned to a given piece. You should also change the UI of a given piece, for example change the border to show the selected piece to a user. Then after clicking a new field for moving the piece you should update the UI by moving your piece view to an appropriate position. Also, the data of a piece or a game should be updated - depending on the place of storing the pieces' positions.
For this you should implement the drag&drop feature which is described here: https://www.tutorialspoint.com/android/android_drag_and_drop.html. You should determine the places where the user can move a piece and in case of dropping the piece in the wrong place, cancel the move and go with the piece to a start position.
Basic response to touch events using event.x and event.y works:
https://developer.android.com/develop/ui/views/graphics/opengl/touch
https://suragch.medium.com/how-touch-events-are-delivered-in-android-eee3b607b038
...more info:
Android Touch Listener
The whole idea of what I'm doing is, creating a notebook use case, where we can have n pages.
Now, I have used RecyclerView and added the item adapter, using the complete screen as a single item for writing.
Now, whenever I start writing on the view which is the property for HW acceleration, I got events but the recycler adapter thinks differently.
How do I solve this? I would like to make sure when writing is happening using a digital pen, the adapter should ignore it, and when we do finger swipe it should move to the next screen/page.
You can use a setOnTouchListener to differentiate between the events. check this links out from SO:
here or here or here
Just need some help. I am currently making an application for our project. My application get the user input which is number because it gets the quantity of the object. My problem is how i will make object to put on it's desired coordinates. Example chair and i enter quantity of 2 then if you click the button you will be directed to next page then you will see the 2 chairs. thats the interface of application when the user use it. but we need to put coordinates to the chair so that it likes generating object and arrange them to our desired coordinates.
Thanks Guys. :)
Do you actually need to calculate screen coordinates yourself? It would probably be easiest to build a LinearLayout and then add items to it in a loop.
See the first answer here for details on how you can do that: Android: Add a textview to linear layout programmatically
You could do the same with a RelativeLayout if you need more complicated positioning, or an AbsoluteLayout if you want total control over positioning. I would be hesitant to use those unless you have a need that's not met with the LinearLayout.
I search for a good and handy user interface to put items from list 1
to a empty list 2 with drag&drop. I need this function for Android 2.2.
Have anybody heard about this feature?
EDIT
I found this website and i think it is also interesting.
http://techdroid.kbeanie.com/2010/04/simple-drag-n-drop-on-android.html
Look also at the comments.
It may also be helpful to reference my simple Drag and Drop list. You can find here
if u don't getting then use this
An example of this in github https://github.com/mtparet/Drag-And-Drop-Android
It could help you.All contribution are welcome
Take a look at this sample that Drag and drop inside a List View..
Refer to the drag and drop API launched in API Version 11
http://developer.android.com/guide/topics/ui/drag-drop.html
A drag and drop operation starts when the user makes some gesture that you recognize as a signal to start dragging data. In response, your application tells the system that the drag is starting. The system calls back to your application to get a representation of the data being dragged. As the user's finger moves this representation (a "drag shadow") over the current layout, the system sends drag events to the drag event listener objects and drag event callback methods associated with the View objects in the layout. Once the user releases the drag shadow, the system ends the drag operation.
i have a listview,now i want to perform on each listview items.I am using GestureDetector.SimpleOnGestureListener,How can i detect that which item is clicked to do desired action.
Plz Help me Out.
You are more likely to find people willing to help if you can post the code that you are currently using and tell about what kinds of problems it is having.
It is also somewhat unclear to me what you're asking so you'll also get better results if you can elaborate some.
Are you trying to capture only "clicks" as in finger touches that item in the list and then lifts back up without moving? Or are you trying to capture gestures like the swipe ("fling") that will move your home screen side to side?
If you're only trying to get clicks ListView has an onItemSelected() method that you can override and it will pass you the position as a parameter. No need for GestureDetector in this case.