本文介绍了TextView的拓展动画像Android电子市场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以点解决方案如何使扩大说明TextView的动画在Android Market的动画?有TextView的裹成的FrameLayout点击更多标签后,它扩展。
Can anyone point to solution how to make expand animation of Description TextView in Android Market animation? There are TextView wrapped into FrameLayout which expands after clicking on 'More' label.
推荐答案
解决方法:
private static int measureViewHeight( View view2Expand, View view2Measure ) {
try {
Method m = view2Measure.getClass().getDeclaredMethod("onMeasure", int.class, int.class);
m.setAccessible(true);
m.invoke(view2Measure,
MeasureSpec.makeMeasureSpec(view2Expand.getWidth(), MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
} catch (Exception e) {
return -1;
}
int measuredHeight = view2Measure.getMeasuredHeight();
return measuredHeight;
}
static public void expandOrCollapse( View view2Expand, View view2Measure,
int collapsedHeight ) {
if (view2Expand.getHeight() < collapsedHeight)
return;
int measuredHeight = measureViewHeight(view2Expand, view2Measure);
if (measuredHeight < collapsedHeight)
measuredHeight = collapsedHeight;
final int startHeight = view2Expand.getHeight();
final int finishHeight = startHeight <= collapsedHeight ?
measuredHeight : collapsedHeight;
view2Expand.startAnimation(new ExpandAnimation(view2Expand, startHeight, finishHeight));
}
class ExpandAnimation extends Animation {
private final View _view;
private final int _startHeight;
private final int _finishHeight;
public ExpandAnimation( View view, int startHeight, int finishHeight ) {
_view = view;
_startHeight = startHeight;
_finishHeight = finishHeight;
setDuration(220);
}
@Override
protected void applyTransformation( float interpolatedTime, Transformation t ) {
final int newHeight = (int)((_finishHeight - _startHeight) * interpolatedTime + _startHeight);
_view.getLayoutParams().height = newHeight;
_view.requestLayout();
}
@Override
public void initialize( int width, int height, int parentWidth, int parentHeight ) {
super.initialize(width, height, parentWidth, parentHeight);
}
@Override
public boolean willChangeBounds( ) {
return true;
}
};
这篇关于TextView的拓展动画像Android电子市场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!