【发布时间】:2013-02-01 17:23:14
【问题描述】:
我正在尝试在 LinearLayout 到 Animation 上执行平滑过渡(展开/折叠)。这是我用于动画的代码:
Animation anim = new Animation(){
@Override
protected void applyTransformation(float interpolatedTime, Transformation t){
super.applyTransformation(interpolatedTime, t);
layout.getLayoutParams().height = (int)(84*interpolatedTime);
layout.requestLayout();
}
};
问题在于展开/折叠动画效果很好,但动画完成后布局本身并不能正确显示。下面的灰色渐变块是它的样子(而不是 textview 和 edittext):
即使我正在调用layout.requestLayout();,但它仍然不会在每个 interpolatedTime 时间刷新布局图。我这里有什么遗漏吗?
附注我在设置高度时使用 84 的原因是因为我知道我的布局的渲染高度,并且它仅在测试/调试过程中静态定义。
【问题讨论】:
标签: android animation height android-linearlayout gradient