我想實現一個縮放動畫查看(或ImageView),當它獲得焦點。這是我目前的執行:獲得焦點時,在一個View/ImageView上實現Android縮放動畫嗎?
public class ScaleFocusImageView extends ImageView {
private Context mContext;
public ScaleFocusImageView(Context context, AttributeSet attr) {
super(context, attr);
mContext = context;
}
@Override
protected void onFocusChanged (boolean gainFocus, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
if(gainFocus) {
Animation a = AnimationUtils.loadAnimation(mContext, R.anim.scale_up);
this.startAnimation(a);
}
}
}
這裏是我的動畫XML「scale_up.xml」:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="1.0"
android:toXScale="1.5"
android:fromYScale="1.0"
android:toYScale="1.5"
android:pivotX="50%p"
android:pivotY="50%p"
android:duration="175"/>
</set>
得到集中在年底的時候,我不能獲得規模效應,我剛纔看到它正常快速縮放並縮小到原來的大小。爲什麼這個實現不能如我所期望的那樣工作,我該如何解決它?
的動畫作品所以實際上你想要什麼?希望動畫應該留在焦點上imageview? –
我希望在焦點時縮放視圖,並在僞裝消失時變爲正常尺寸,謝謝 – gladman
確定讓我檢查我的機器 –