誰かがAndroidのアニメーションについて知っていますか?次のようなものを作成します:Androidでのアニメーションの移動/サイズ変更の作成方法
- 私は自分のデバイス画面の中央に大きな画像を持っています。
- このイメージは小さくなり(アニメーションによって)、デバイスの画面の角に移動します。
その本怒鳴るシーケンスのようなもの:
任意のヒントは非常に高く評価されるだろう!前もって感謝します!
誰かがAndroidのアニメーションについて知っていますか?次のようなものを作成します:Androidでのアニメーションの移動/サイズ変更の作成方法
その本怒鳴るシーケンスのようなもの:
任意のヒントは非常に高く評価されるだろう!前もって感謝します!
scaleXBy()
およびtranslateYBy()
のような方法でViewPropertyAnimator
を使用してください。 APIレベル11以上のをView
に呼び出してViewPropertyAnimator
を取得します。古いデバイスをサポートしている場合は、NineOldAndroidsには作業現場に近いバックポートが用意されています。
また読みたいかもしれません:
私は同時に回転や移動を持つクラスを持っています。高価ですが、すべてのAPIバージョンで動作します。
public class ResizeMoveAnimation extends Animation {
View view;
int fromLeft;
int fromTop;
int fromRight;
int fromBottom;
int toLeft;
int toTop;
int toRight;
int toBottom;
public ResizeMoveAnimation(View v, int toLeft, int toTop, int toRight, int toBottom) {
this.view = v;
this.toLeft = toLeft;
this.toTop = toTop;
this.toRight = toRight;
this.toBottom = toBottom;
fromLeft = v.getLeft();
fromTop = v.getTop();
fromRight = v.getRight();
fromBottom = v.getBottom();
setDuration(500);
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float left = fromLeft + (toLeft - fromLeft) * interpolatedTime;
float top = fromTop + (toTop - fromTop) * interpolatedTime;
float right = fromRight + (toRight - fromRight) * interpolatedTime;
float bottom = fromBottom + (toBottom - fromBottom) * interpolatedTime;
RelativeLayout.LayoutParams p = (LayoutParams) view.getLayoutParams();
p.leftMargin = (int) left;
p.topMargin = (int) top;
p.width = (int) ((right - left) + 1);
p.height = (int) ((bottom - top) + 1);
view.requestLayout();
}
}
yip ...うまく動作します – Houston
これはすごくうまくいきます!ありがとう! – instanceof
このリサイズアニメーションを前述のビューで呼び出す方法 – shobhan
ありがとうCommonsWare。確かに、これは大きな助けになる! – mthama