Android 如何将视图的底色设置为白色
我想将视图的背景色设置为白色,但它是黑色的。我该怎么做?我这样试过:Android 如何将视图的底色设置为白色,android,background-color,Android,Background Color,我想将视图的背景色设置为白色,但它是黑色的。我该怎么做?我这样试过: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); View someView = findViewById(R.id.myScreen); // Find the root view
@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>
使用
使用android.R.color.white代替
代替android.R.color.white在线性布局中简单设置android:background=ffffff。在线性布局中简单设置android:background=ffffff。是的,尝试此root.setBackgroundColorColor.white 是的,试试这个root.setBackgroundColorColor.WHITE 我想你忘记粘贴xml文件了。请出示您的xml文件,以便我们可以帮助您。我想您忘记粘贴xml文件了。请向我们展示您的xml文件,以便我们能够帮助您。如果您认为答案对您和upvote都有帮助,您应该接受答案……:如果您认为答案对您和upvote都有帮助,您应该接受答案……:
root.setBackgroundColor(Color.WHITE);