如何改变背景颜色上的应用程序负载(的onCreate())? [英] How to change color of backGround on app load(onCreate())?
本文介绍了如何改变背景颜色上的应用程序负载(的onCreate())?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图改变R =后面地面上的应用程序负载的颜色。为此,我使用了这样的事情:
I am trying to change r=the color of the back ground on app load. For this I have used something like this :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final View view= new View(getApplicationContext());
view.post(new Runnable() {
@Override
public void run() {
view.setBackgroundColor(Color.BLACK);
}
});
addListenerOnButton();
}
这是行不通的。看到模拟器的屏幕下方打出:
This does not work. See the emulator screen shot below :
正如你所看到的回地面的颜色仍然是白色。在我能做些什么来纠正这种任何想法?
As you can see the back ground color is still white . Any ideas on what i can do to rectify this ?
推荐答案
简单。试试这个方法。
Simple. Try this way.
this.findViewById(android.R.id.content).setBackgroundColor(Color.BLACK);
有关例如:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.findViewById(android.R.id.content).setBackgroundColor(Color.BLACK);
}
下面 findViewById(android.R.id.content)
将返回内容查看
当前活动。然后,您可以设置此观点的背景。
我希望这会帮助你。
Here findViewById(android.R.id.content)
will return ContentView
of current activity. Then you can set background for this view.
I hope this will help you.
这篇关于如何改变背景颜色上的应用程序负载(的onCreate())?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文