黑發不知勤學早,看看又是白頭翁
VideoImageView用于顯示視頻的預覽圖,但是在Meizhi項目中并未觸發效果。我單獨把它弄成一個項目,以下是效果圖。
 布局代碼
 布局代碼
VideoImageViewActivity
@Override PRotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_image_view); mVideoImage = (VideoImageView) findViewById(R.id.video_image); mVideoImage.setImageResource(R.mipmap.ic_launcher); }VideoImageView
public class VideoImageView extends ImageView implements Animator.AnimatorListener { private boolean scale = false; public VideoImageView(Context context) { this(context, null); } public VideoImageView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public VideoImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); nextAnimation(); } private void nextAnimation() { AnimatorSet anim = new AnimatorSet(); if (scale) { anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1.5f, 1f), ObjectAnimator.ofFloat(this, "scaleY", 1.5f, 1f)); } else { anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1, 1.5f), ObjectAnimator.ofFloat(this, "scaleY", 1, 1.5f)); } anim.setDuration(10987); anim.addListener(this); anim.start(); scale = !scale; } @Override public void onAnimationCancel(Animator arg0) { } @Override public void onAnimationEnd(Animator animator) { nextAnimation(); } @Override public void onAnimationRepeat(Animator arg0) { } @Override public void onAnimationStart(Animator arg0) { }}Android屬性動畫完全解析(上),初識屬性動畫的基本用法 Android屬性動畫完全解析(中),ValueAnimator和ObjectAnimator的高級用法 Android屬性動畫完全解析(下),Interpolator和ViewPropertyAnimator的用法
新聞熱點
疑難解答