Is it possible to set the background color on glass [gdk-immersion]?

丶灬走出姿态 提交于 2019-11-28 06:10:56

问题


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.

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" >

Any help or workaround would be appreciated.


回答1:


The way I solved this issue is by setting the following line in my layout:

 android:background="@color/black"

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.



来源:https://stackoverflow.com/questions/21394858/is-it-possible-to-set-the-background-color-on-glass-gdk-immersion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!