Android-以编程方式应用TransitionDrawable-问题
当用户选择不同的选项时,我试图改变背景颜色 为此,我在运行时创建TransitionDrawable。它很好用。但是 我的问题是,当我使用setDrawableBackground()更改视图背景时,一半的屏幕视图被形状drawable覆盖 这是我的TransitionDrawable代码Android-以编程方式应用TransitionDrawable-问题,android,transition,shapedrawable,transitiondrawable,Android,Transition,Shapedrawable,Transitiondrawable,当用户选择不同的选项时,我试图改变背景颜色 为此,我在运行时创建TransitionDrawable。它很好用。但是 我的问题是,当我使用setDrawableBackground()更改视图背景时,一半的屏幕视图被形状drawable覆盖 这是我的TransitionDrawable代码 public static TransitionDrawable getTransitionDrawable (ShapeDrawable start, ShapeDrawable end){ Sha
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);
帮我解决我的问题
提前谢谢