I got an app that utilizes drag and drop, and I want to reset the position of ImageViews (and then also the parent of the dragged image I guess).
I can't find any good info, and Google is no help.
Related
enter image description here
I am placing the layouts on approprite positions by dragging and dropping but in the emulator when opened they are all at the same position . please help
Android studio does not work that way. You cannot set the positions of views(items) by dragging them and placing them. You will have to set the constraints on the attribute tab. You can find the attribute tab at the top left corner. It is visible in the picture you uploaded. Click on that and the attributes window will open.
Then, when you click on a view, there is a square that appears in the attribute window. That square has 4 + signs around it. You have to click on one of the left or right + signs and enter a number. That would determine the horizontal position (distance from left or right margin) of the view.
Similarly, set the vertical position by clicking on to our bottom +.
This is the method used to set the position of views graphically. There is a way to set them in the xml code. I guess you are not familiar with it. You will get to know how to do it inxml as you go on with Android development.
You can also set the position of a view with reference to other views instead of the margins. Please watch this video to know more about constraints.
When you select one of your layout items, you'll see anchors on the sides.
Move an arrow from the selected view to the next one (or surrounding parent) to add a layout constraint.
An easy overview and quickstart how to use constraints in android studio, can be found here:
https://constraintlayout.com
And in the official documentation here:
https://developer.android.com/training/constraint-layout
I made an App for my children.
The problem is that he hold the tablet with the thumbs slightly inside the view margins.
By doing so, he can't click on view's buttons while one hand is holding the device.
There is a way to ignore all the long presses on the entire App?
My aim is to let him to click on the view's button while holding the device with thumbs inside the view margins.
I already searched with Google but without lucky.
Thanks in advance!
I integrated Drag And Drop Framework in my project. In the layout I have my own custom grid of cells that I want to be able to drag for swipe the order of them or to put 2 together in folder.
To achieve this what I did is to build custom RelativeLayout and to override the onDragEvent() callback.
Basically everything working fine, but I have issues when in the dragging process I put 2 cells into big folder .
This folder is in layout from the start of the process with GONE visibility ,and I change it visibility to VISIBLE with copy of those cells. The problem is that the RelativeLayout folder have issues with the stream of the Drag events. The stream is stop sometimes and continue just if I stop the movement for some time.
I think of moving all the dragging logic to the parent so just 1 view will get all the event but I really prefer to find solution and stay with my logic because it taking advantage the framework data about which View is currently below the Dragging view.
After a lot of tries and research I found out that the Drag And Drop Framework stops to send most of the DragEvents when the alpha prperty of the View is different from 1.
i'm using Eclipse to make an android app. I'm a beginner and i'm wondering how on earth I can place an image on my page where ever I want. It keeps locking in certain places due to alignments. Surely you must be able to click the image view and drag it into the desired place??
thanks
If you use RelativeLayout or FrameLayout as a container, you can place the inner Views wherever you want. They still have to be aligned somehow, but by changing the margins they can be on every position in the parent.
I have developed Darggable grid view,In this Grid View I have Implemented Darg and Drop Functionality It's Working fine.But As per my requirement I need to integrate this code into
ViewPager.BUt I couldnot drag the icons from one view to another view.I can Drag the icons only one view.Can You PLease solve this if any one knows.
I have implemeted darg&drop functionality using this article:https://github.com/thquinn/DraggableGridView
DraggableGridView only supports rearranging within one instance. You would need to implement custom events to give your activity information about the currently selected view. You'd have another problem: by default, views don't draw outside of their parent ViewGroup. You might want to try Android's Drag and Drop framework to develop your own custom behavior.
http://developer.android.com/guide/topics/ui/drag-drop.html