如何在登录和注册页面上更改我的android工作室应用程序背景颜色,如Instagram的当前背景更改器?我希望每2秒更换一次颜色,但我希望背景能够慢慢消失而不会不断闪烁。我有这个代码,但它似乎不起作用:
new CountDownTimer(5000, 1000) {
public void onTick(long millisUntilFinished) {
v.setBackgroundColor(0xFF00FF00 + millisUntilFinished / 1000);
}
@Override
public void onFinish() {
v.setBackgroundColor(0xFF00FF00);
}
}.start();
}
编辑!!!!这个链接对我不起作用
registeractivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
screen = (RelativeLayout) findViewById(R.id.screen);
(new Thread(){
@Override
public void run(){
for(final int i = 0; i<255; i ++){
handler.post(new Runnable(){
public void run(){
screen.setBackgroundColor(Color.argb(255, i, i, i));
}
});
// next will pause the thread for some time
try{
try {
sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
catch {break;}
}
}
}).start();
activity_register:
android:id="@+id/screen"