Android: how to hide and then show View with animation effect?

Posted by tomash on Stack Overflow See other posts from Stack Overflow or by tomash
Published on 2010-03-22T21:16:33Z Indexed on 2010/03/22 21:21 UTC
Read the original article Hit count: 762

Filed under:
|
|
|
|

I have similar question like this one: http://stackoverflow.com/questions/2079074/update-layout-with-the-animation

Basically: I have one vertical LinearLayout View with edittext, button and then list. I'd like to hide exittext after pressing button to make more space for list (button will go up). On second press edittext should be visible again. Edittext and button have "wrap_content" height.

I'd like to hide and show edittext with animation.

I succeeded to animate hiding by overloading Animation's applyTransformation:

final float edittextheight= edittext.getHeight();
[....]
@Override
protected void applyTransformation(float interpolatedTime,
        Transformation t)
{
    super.applyTransformation(interpolatedTime, t);
    android.view.ViewGroup.LayoutParams lp = edittext.getLayoutParams();
    lp.height = (int)(edittextheight*(1.0-interpolatedTime));
    edittext.setLayoutParams(lp);
}

Problem:

I don't know how to calculate height to animate showing - edittext.getHeight(); returns 0 when widget is hidden and in layout definition I'm using "wrap_content".

Help?

© Stack Overflow or respective owner

Related posts about android

Related posts about animation