1
クリックがあるときにビューの高さをmatch_parentに変更するにはどうすればよいですか?androidのアニメーションと一致する高さのビューを設定
public class ResizeAnimation extends Animation {
final int startHeight;
final int targetHeight;
private final boolean isOpen;
View view;
public ResizeAnimation(View view, int height, boolean isOpen) {
this.view = view;
this.targetHeight = height;
this.isOpen = isOpen;
startHeight = view.getHeight();
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
int newHeight;
if (isOpen) {
newHeight = (int) (startHeight + (targetHeight - startHeight) * interpolatedTime);
} else {
newHeight = (int) (startHeight + targetHeight * interpolatedTime);
}
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;
}
}
ResizeAnimation resizeAnimation = new ResizeAnimation(view, MATCH_PARENT, false);
resizeAnimation.setDuration(500);
view.startAnimation(resizeAnimation);