Android: Sliding Drawer Style Animation - android

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.

Related

Scrollbars show up when animating container with textviews (How can i disable it?)

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"

Android Animation - Button stays clickable

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 :)

Alternative to Translate Animation

I finally came to know that when using translate animation, the button onclick listener won't work.
This is the link to the full description of my problem
Now I would like to know what is the alternative options to try instead of Translate Animation.
You can use your own animation using a thread.
I can give you an example.
Put your view to animate inside a Relative Layout.
Then start a thread which is running a loop with specific delay time and then set the margin of the view that you need to animate with different values..
This will give you the effect of translate animation and the view will be intractable also.

TranslateAnimation, occur on top

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.

Android: Move View after animation?

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.

Categories

Resources