如何将背景颜色设置为白色
我想将背景颜色设置为“白色”,但是它是黑色的。我该怎么做呢?我尝试了这种方式:如何将背景颜色设置为白色
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View someView = findViewById(R.id.myScreen);
// Find the root view
View root = someView.getRootView();
// Set the color
root.setBackgroundColor(android.R.color.white);
}
和main.xml中的文件是...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/myScreen" >
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/Button" android:text="Play Sound"></Button>
</LinearLayout>
使用
root.setBackgroundColor(Color.WHITE);
,而不是android.R.color.white
确定为我工作 – SRam 2011-05-06 11:25:35
简单的设置android:background="#ffffff"
在你的LinearLayout 。
谢谢..工作 – SRam 2011-05-06 11:23:04
你应该接受答案,如果你认为它对你有帮助,upvote太.... :) – 2011-05-06 11:57:08
我想你忘了粘贴您的XML文件。请向我们展示您的XML文件,以便我们可以帮助您。 – Varundroid 2011-05-06 11:13:45