I got a question regarding TranslateAnimation. Is it possible to force the the animation to occur
on top of other views? I'm trying to translate the first child on top of the other elements in a LinearLayout.
I thought setZAdjustment would do the job, but it didn't work as expected.
I can see why that wouldn't work as expected.
Try customizing your LinearLayout to one which overrides getChildDrawingOrder() and thereby force it to draw your animated child last.
Related
I have a simple view containing a scene root FrameLayout, ListView and a couple of buttons on the bottom.
scene root is used to load and show different scenes, the size changes dynamically depending on the current scene. ListView is set to match_parent in both directions and is positioned behind scene root.
Here's the issue:
If I start a transition using the buttons on the bottom everything works ok, no problem, magic. However, if I transition (✝) to a different scene while scrolling (✝✝) the transition seems to flicker before starting.
It almost looks like the rendering engine fails to load the first frame of the animation before the ListView invalidates the hierarchy due to scrolling.
Thanks for the help ;)
✝ TransitionManager.go(Scene, Transition)
✝✝ I've added a couple of methods to the ListView to allow that
All the Google apps that use Scene Transition that I've seen transit from some item in a ListView to its detail Activity. Since ListView has the convenient behavior of immediately stop the scrolling when touched, such a transition doesn't produce flickering.
So it appears the best thing to do may be to programmatically stop the scrolling before transiting to the new Activity, which is accomplished by the code here.
I currently have two fragments inside views. The views are animated around the screen.
On most devices there is no problem. However on some devices including the simulator, the visuals inside each of the fragments becomes jagged and smears while the animation is taking place. As soon as the animation is finished then it appears normally.
Im guessing that the draw commands inside the fragments are not getting called when the containing view is being animated. Is there any way I can force the fragments to redraw on every frame of the animation?
Thanks.
Invalidate your parent view while animating :)
Im using a simple ValueAnimator to animate a LinearLayout's height UP or DOWN.
As I add a new child I use a onPreDrawListener to set the height to what it was prior to the child being added, and then I simply animate the height to the new height.
The animation works good. Problem is, since the TextView isnt fully visible at the start it shows a small scrollbar next to it until its content can be seen on screen.
My question is, how can I totally disable this scrollbar?
Ive tried setting the scrollbars value in xml to none with no change, Ive also tried changing the default fade delay of the scrollbar but it doesnt seem to affect it at all.
Hope theres someone out there who knows a solution. Thanks in advance!
Solved it by creating the TextView through XML and adding these two lines.
android:scrollbarThumbVertical="#android:color/transparent"
android:scrollbarTrackVertical="#android:color/transparent"
I am making a game in which I have 5 buttons, looking like clouds, falling from the "sky".
That means that when my activity starts, 'clouds' cannot be seen, since the marginTop is set to -100dp.
From that position they start falling down untill they get lost on the bottom side of the screen.
The thing is, I need those buttons to be clickable, during the process of animation.
So far, I found some documentation about how I can make the buttons clickable AFTER the animation ends. But I don't need that. I need to be able to click on the buttons through the animation time itself.
NOTE: I need something that works with versions before 3.0.
Anybody has any link to documentation or some example or anything ?
After doing some research, I found out that there are two types of animations:
View Animation and Property Animation.
The view animation can only animate View objects. It also lack a variety of animations, since it can do only stuff as scale, rotate, move... It cannot change background color, for example.
Also, the disadvantage of the View Animation is that it only change the position of where the View object is DRAWN. Physically, it still stays in the same position.
That's why the button is un-clickable, after the View Animation is finished upon it.
Property Animation, in the other hand, can animate both View and non-View objects and it doesn't have constraints as the View Animation.
When objects are moved, for example, with the property animation, they are not just drawn on some other position on the screen, but they are actually MOVED there.
Now, Property Animation is a lot more complex to write than the View Animation, so if you don't really need all the advantages of the Property Animation, it is suggested to use View Animation.
Source:
Property vs View Animation
Tutorial and SupportLybrary up to API 1:
nineoldandroids
You can change the buttons to imageViews and then do
imageView.setOnClickListener(myListener)
then set myListener to do whatever you previously wanted to happen on the buttons onClick. Your activity will have to implement OnClickListener
Added bonus: you can make the images look like clouds :)
I am looking to animate a LinearLayout of mine.
I would like to make it move upward while looking like it is disappearing behind a line (View of height 1dp) above it, until it is finally completely gone. Then when I want to show it I would like to be able to reverse that.
I am kind of lost as to how to achieve this. My first thought was that I could maybe convert my Layout into a Clip-Drawable somehow and use a TranslateAnimation and change how much of it can be seen, but that seems overly complicated and difficult. How could I make an animation (maybe a set of animations?), or otherwise to achieve this effect?
If the 1dp line is within a larger view, your LinearLayout can be animated to disappear behind it. Use TranslateAnimation with an animation listener, then in onAnimationEnd, you can set the visibility of your LinearLayout to View.GONE.