【发布时间】:2013-05-15 02:05:13
【问题描述】:
您好,我是 android 开发的新手,我期待一种更改背景颜色的方法。
这是我的代码:
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// View layout = new View(this);
// layout.setBackgroundColor(android.R.color.holo_blue_light);
// View root = layout.getRootView();
// root.setBackgroundColor(android.R.color.holo_green_dark);
View view = this.getWindow().getDecorView();
view.setBackgroundColor(R.color.red);
【问题讨论】:
-
使用 setBackgroundResource() 代替 setBackgroundColor()
-
或更改布局文件中的背景