问题描述
我的玻璃项目沿很大的到来。
my glass project is coming along great.
我想知道是否有可能改变一个视图的背景颜色。我使用的是浸泡在该单一视图我的整个应用程序运行。整个视图是一个相对布局。
I am wondering if it is possible to change the background color of a view. I am using an immersion and my entire app runs on that single view. The entire view is a relative layout.
我最初试图从本code。通过我的定义相对布局和做: rl.setBackgroundColor(color.empty_gray);
,但不能更改发生时,此code的调用。然后我试图用安卓直接将它的XML元素:背景=@色/ warning_red
这也没有产生
I originally tried to this from code by defining my relative layout and doing: rl.setBackgroundColor(color.empty_gray);
But not change occured when this code was called. Then I tried adding it directly to the XML element with android:background="@color/warning_red"
which also yielded nothing.
它是不可能改变视图的背景颜色?我知道你可以设置在卡的图片背景,但浸泡真正起作用太多我的应用程序更好。我可以将图片设置背景颜色,将这项工作?
Is it impossible to change the background color of the view? I know you can set a picture background in a card but the immersion really works much better for my application. Can I set a picture background with a color, would that work?
下面是我的整个相对布局设置:
Here is my entire relative layout setup:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rel_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:keepScreenOn="true"
android:background="@color/warning_red"
tools:context=".MainActivity" >
任何帮助或解决方法是将AP preciated。
Any help or workaround would be appreciated.
推荐答案
我解决这个问题的方法是通过设置下面一行在我的布局:
The way I solved this issue is by setting the following line in my layout:
android:background="@color/black"
然后我创建的文件夹值的文件,把它称为colors.xml并把颜色编码
And then I created a file in the folder VALUES, called it colors.xml and put the color coding
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#ff000000</color>
</resources>
我不记得在那里我读到这一点,但它确实工作,为我沉浸玻璃器皿。
I don't remember where I read this, but It did work for my immersion glassware.
这篇关于是否可以设置背景色玻璃[GDK沉浸]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!