【发布时间】:2010-03-22 21:16:33
【问题描述】:
我也有类似的问题:Update layout with the animation
基本上:我有一个带有编辑文本、按钮和列表的垂直 LinearLayout 视图。我想在按下按钮后隐藏退出文本以便为列表腾出更多空间(按钮会上升)。在第二次按下edittext 应该再次可见。 Edittext 和按钮的高度为“wrap_content”。
我想用动画隐藏和显示edittext。
我通过重载Animation的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);
}
问题:
我不知道如何计算高度以动画显示 - edittext.getHeight();当小部件被隐藏并且在布局定义中我使用“wrap_content”时返回 0。
帮助?
【问题讨论】:
标签: android animation layout hide