I have one absolute layout which contains many ImageViews. I have implemented Drog and Drop functions for all imageview. Now what happen when suppose i drag one imageview over another imageview then first view goes back side because it have been added first compaire to another one . I need that moving view always visible on top.
So can i solve this problem ?
Thanks in advance.
Probably the easiest way to avoid this is to call .bringToFront() on your ImageView when you begin your dragging code.
http://developer.android.com/reference/android/view/View.html#bringToFront%28%29
Related
I have a GridView, I want to move one of the ImageView inside one of the item of this GridView, I want to move it on screen using a TranslateAnimation and put it in a corner of the screen for example. I'm fine with the animation, the problem is that the View can't be moved out of its layout without disappearing. Which is totally normal.
My question is: What is best way to animate a view wherever I want on the screen ? Should I add it the the main layout of my activity and then move it? Or is there is a way similar to the iOS clipToBounds ?
Thanks!
Okay found android:clipChildren="false", and it works
I want to move, in an anmiated way, a TextView in a LinearLayout into another LinearLayout.
However, I can't get it to move outside its container view (the LinearLayout it is in), it only moves inside this. Can someone help me to get this done? Also see the following image:
I'm using the NineOldAndroids library and have tried with the ViewPropertyAnimator:
animate(myTextView).setDuration(500).x(?).y(?);
And also with:
animate(myTextView).setDuration(500).translationX(?).translationY(?);
Instead of the '?' in above I want to be able to find out the position of the LinearLayout I want to drop the TextViews in. (If it's not possible to move to a certain View by stating the View-object).
What need to be done is to add "android:clipChildren="false"" to all the container layouts.
I build a Listview, each item of this Listview in a layout composed of a Gallery.
On click of an item of the Gallery, I want to translate it to the top of my screen.
Even with setZAdjustment(Animation.ZORDER_TOP); my gallery cell doesn't move outside the gallery.
I assume it's because it can't go outside it's parent view.
Is there a way to do this ?
Thanks
I assume it's because it can't go outside it's parent view.
you are right.
There is no way that you can move that exact view. What you can do is make yourself a new ImageView and add it to your top level layout right over the top of the selected cell. Set its image by calling .getDrawingCache() on the gallery cell. Then you can animate your new ImageView to where ever you want.
Depending on what you want to do with it once it has been moved this might work out for you. But fair warning it is a somewhat convoluted process to achieve the effect you're after
Im new to Android and over the past few days I have been over many tutorials, I was wondering if you could help me with some advice.
I want images on top of each (not completely, there may be some overlapping) other with each image to be clickable.
Whats the best way to do this? Have each image in an image view? Can these be positioned on top of each other? And have onclick listeners?
Thanks for your help
Imageviews can be stacked by using the framelayout. The framelayout add each child view on top of each other based on the order of the childs ie the last child will be the top most.
Jep, ImageViews are appropriate. Add them to a RelativeLayout and add a onClickListener and you are done.
Have a close look at RelativeLayout's align* attributes.
HTH.
I am trying to develop a puzzle that lets you drag the puzzle part to another part in the puzzle. This drag event shall swap the 2 parts (Images in my case).
I made the first part of the puzzle by making a GridView that contains the puzzle parts as ImageViews and a blank position. So, clicking on an image checks if it is neighboring the blank position. If it is neighboring, they swap. Otherwise, nothing happens because this part can not move.
Can anyone suggest how can I change "clicking" the image to "moving" the image to do the swap operation?
I put together a drag-and-drop grid view that you can get here:
https://github.com/thquinn/DraggableGridView
You'll have to change the animateGap(...) and reorderChildren() methods to get your intended behavior, but it should suit your needs.
you can use the onclicklistener to get the clicked image.
To 'move' the image try using addviewat() and removeview() functions on gridview to remove
and add the views.