필자는 RelativeLayout 안에 높이가 fill_parent이고 처음 상단 여백이 200dp 인 LinearLayout (레이아웃이라고 함)이 있습니다. 버튼을 클릭하면 topMargin을 0으로 설정하여 LinearLayout을 확장합니다. 나는 다음 코드를 사용하고 있습니다 :부드럽게 Android 애니메이션 만들기
final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT);
Animation animation = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime,
Transformation t) {
int topMargin = (int)((1-interpolatedTime)*200);
layoutParams.setMargins(0, topMargin, 0, 0);
layout.setLayoutParams(layoutParams);
LogThis.debug("topMargin: "+topMargin);
}
};
animation.setDuration(1000);
layout.startAnimation(animation);
문제는이 애니메이션을 수 있지만, 그것은 부드러운 아니라고이다. 그것은 4 단계로 변환을하므로 좋지 않습니다.
이러한 종류의 변환을 부드럽게하는 방법을 알고 있습니까?
미리 감사드립니다.
를 그리고 애니메이션 후에 나는이 원하는 :
편집
나는이 첫 번째 순간이 내가 얻을 TranslationAnimation와
을 this :
즉 애니메이션을 사용할 수 해야하는없는 방법이기 때문에
을하지만, 전체 공간을 ocupy하지 않습니다. 나는 그것을 성장시킬 필요가있다. (내부의 이미지가 아닌 레이아웃의 크기를 조절한다.) – user1448668