我想创建View
形状的变换动画。例如,将rectangle
更改为oval
。我试着用彩色动画做同样的事情:
ColorDrawable[] color = {new ColorDrawable(Color.RED), new ColorDrawable(Color.BLUE), new ColorDrawable(Color.RED)};
TransitionDrawable drawable = new TransitionDrawable(color);
drawable.startTransition(1000);
image.setBackground(drawable);
但是当我尝试使用ShapeDrawable[]
时,我无法塑造转型,但imageView
变黑了。
float[] outerR = new float[] {4, 4, 4, 4, 4, 4, 4, 4};
ShapeDrawable oval = new ShapeDrawable(new OvalShape());
ShapeDrawable rect = new ShapeDrawable(new RoundRectShape(outerR, null, null));
rect.setBounds(0,0,120,120);
oval.setBounds(0,0,120,120);
ShapeDrawable [] draws = {rect, oval};
TransitionDrawable drawable = new TransitionDrawable(draws);
drawable.startTransition(1000);
image.setBackground(drawable);
那么在Android中有任何编程方式可以顺利转换(更改View
的形状吗?