如何以编程方式将活动的背景颜色设置为白色? [英] How to set background color of an Activity to white programmatically?
本文介绍了如何以编程方式将活动的背景颜色设置为白色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将活动的背景颜色设置为白色?
How can I set the background color of an Activity to white programatically?
推荐答案
,然后设置背景颜色。根布局是你调用的setContentView。
Get a handle to the root layout used, then set the background color on that. The root layout is whatever you called setContentView with.
setContentView(R.layout.main);
// Now get a handle to any View contained
// within the main layout you are using
View someView = findViewById(R.id.randomViewInMainLayout);
// Find the root view
View root = someView.getRootView();
// Set the color
root.setBackgroundColor(getResources().getColor(android.R.color.red));
这篇关于如何以编程方式将活动的背景颜色设置为白色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文