0
我有一個LinearLayout(稱爲佈局),其高度爲fill_parent,在RelativeLayout中的初始頂邊距爲200dp。 當我點擊一個按鈕時,我想讓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我得到這個:
那輕輕移動的佈局,但它並不按觀測整個空間。我需要它增長(調整佈局,而不是其中的圖像)。 – user1448668