从左到右过渡

时间:2015-04-24 03:31:37

标签: android

我使用下面的代码设置了migrationdrawable来改变颜色,但我想从左到右改变颜色。我该怎么做?

final Button b=(Button)findViewById(R.id.button);
        //Let's change background's color from blue to red.
        ColorDrawable[] color = {new ColorDrawable(Color.BLUE), new ColorDrawable(Color.RED)};
        TransitionDrawable trans = new TransitionDrawable(color);
        //This will work also on old devices. The latest API says you have to use setBackground instead.
        b.setBackgroundDrawable(trans);
        trans.startTransition(1500);

0 个答案:

没有答案