当用户选择不同的选项时,我试图更改背景颜色。
为此,我在运行时创建了 TransitionDrawable。它工作正常。但我的问题是当我使用 setDrawableBackground() 更改视图背景时,我的一半屏幕视图被可绘制形状覆盖。
这是我的 TransitionDrawable 代码,
public static TransitionDrawable getTransitionDrawable (ShapeDrawable start, ShapeDrawable end){
ShapeDrawable[] mDrawableSet = {start,end};
TransitionDrawable tDrawable = new TransitionDrawable(mDrawableSet);
return tDrawable;
}
这是我的 ShapeDrawble 创建代码
public static ShapeDrawable getShapeDrawable (int[] colors){
ShapeDrawable mDrawable = new ShapeDrawable(new RectShape());
SweepGradient sg = new SweepGradient(0, 1,colors , null);
mDrawable.getPaint().setShader( new SweepGradient(0, 0,colors , null));
return mDrawable;
}
我写了下面的代码来应用颜色过渡
holder.setBackgroundDrawable(AnimUtils.DEFAULT_TO_SUCCESS_TRANSITION);
transition = (TransitionDrawable) holder
.getBackground();
transition.startTransition(2000);
帮我解决我的问题...
提前致谢。