[英]Android Background color change
This is the XML file blog.xml 这是XML文件blog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:id="@+id/info"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#FFFFFF">
</LinearLayout>
.java file .java文件
super.onCreate(savedInstanceState);
setContentView(R.layout.blog);
View linearLayout = findViewById(R.id.info);
TextView valueTV = new TextView(this);
valueTV.setText("hallo");
valueTV.setId(5);
valueTV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
((LinearLayout) linearLayout).addView(valueTV);
}
Here i need the entire Activity to be turned white.But while compiling this program, the text written has white background.ie "hallo" word has the white background. 在这里,我需要将整个活动变成白色。但是在编译该程序时,编写的文本具有白色背景。即“你好”一词具有白色背景。
Please help. 请帮忙。
It's because your LinearLayout
in the XML has the height and width set to wrap_content
. 这是因为XML中的LinearLayout
的高度和宽度设置为wrap_content
。 Change this to fill_parent
to fill the whole activity. 将其更改为fill_parent
可以填充整个活动。 At the moment it is just wrapping the TextView
. 目前,它只是包装TextView
。
change 更改
android:layout_width="wrap_content"
android:layout_height="wrap_content"
in your xml to 在您的xml中
android:layout_width="fill_parent"
android:layout_height="fill_parent"
use this.. 用这个..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:id="@+id/info"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF">
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.