how to set back ground color of view to white
I want to set background color of view to "white" but it is black. How do I do this? I tried it that way:
@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);
}
and main.xml file is...
<?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="@开发者_StackOverflow+id/Button" android:text="Play Sound"></Button>
</LinearLayout>
Simple set android:background="#ffffff"
in your linearLayout.
yes try this root.setBackgroundColor(Color.WHITE);
Use
root.setBackgroundColor(Color.WHITE);
instead of android.R.color.white
精彩评论