查看背景色动画
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查看背景色动画相关的知识,希望对你有一定的参考价值。
import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; public class BGColorTransitionDrawable extends TransitionDrawable { private int interval; public BGColorTransitionDrawable(Drawable[] layers) { super(layers); interval = 500; initVars(); } public BGColorTransitionDrawable(Drawable[] layers, int interval) { super(layers); this.interval = interval; initVars(); } private void initVars(){ setCrossFadeEnabled(true); setId(0,0); setId(1,1); } public void changeColor(int color){ setDrawableByLayerId(0, getDrawable(1)); setDrawableByLayerId(1, new ColorDrawable(color)); startTransition(interval); } } I set and call it like so. ColorDrawable layers[] = new ColorDrawable[2]; layers[0] = new ColorDrawable(0xff0000ff); layers[1] = new ColorDrawable(0xffff0000); backgroundColorAnimation = new BGColorTransitionDrawable(layers); vColorSwapper.setBackgroundDrawable(backgroundColorAnimation); backgroundColorAnimation.setColor(0xff00ff00);
以上是关于查看背景色动画的主要内容,如果未能解决你的问题,请参考以下文章