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
Related
I'm trying to implement a sliding menu, like in Prixing app. (The menu which lays under main layout and get visible when you take and drag main layout to the side)
But the trick is - i want it to appear on bottom of the screen, so I need to move the main layout to the top.
The second problem is that in tah layout I got a listview.
Please, I really need advices or maybe link to some usefull resources where I can understand how touch events are handled.
Thx!
i think you are try to do same as facebook app. i have found demo for it. so use this
there's really no magic on it.
To make it, move directly (in a button click or something):
you use a animation to change the LayoutParams.top from both fragments (the one on top (currently in view, and the one on the bottom, hidden under the screen).
On your XML layout make sure to set a fixed height for the bottom layout (in DIP) and during runtime animate the two layouts to move that amount of pixels.
To make it move with the user finger:
That will be tricky, because the listview MUST receive the the user input. Maybe if you call super on it.
But you can accomplish it by receiving OnTouchEvents:
TOUCH_DOWN, you start the move (mark it with a boolean or something)
TOUCH_MOVE, you apply the same change to the layout params that you did on the animation (1st option)
TOUCH_UP or TOUCH_CANCEL, you stop the move (clear the flag).
hope it helps pointing you to the right direction.
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
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
I started with a simple animation on button,
I am successful to an extent,
The problem i am facing is, I am able to animate the button but the position of listener,
Even after button is animated the clickable area is not animated , It is resting at the original postion
Could some one help me with an useful code snippet or suggestion
Regards
Android animations can not change the layout of buttons or view in general. Only their image will appear to move, but they will stay in the same place. After the animation is finished, get the Layout parameters through View.getLayoutParams() and change them.
I'm trying to basically have a button move down to the bottom of the screen with an animation after it is clicked.
I have the animation working perfectly, but the button doesn't stay at the bottom of the screen after the animation finishes. I've tried using offsetTopAndBottom(), but it only stays down there for one frame, and is redrawn at the top. How can I get the button to stay?
Did you try to call setFillAfter(true) on your animation instance?
Regards!
Yes, setFillAfter(true) works.
But the strange thing is that corresponding android:fillAfter XML attribute does not provide same effect. Be aware, guys.
Your button is not clickable because you are using View animation instead of the Property Animation.
View animation only change where your View is drawn instead of really moving it to that location.
Property animation does the trick.
I answered your question on another thread.
You can check it out here.