Search code examples
android-layoutgoogle-glassgoogle-gdk

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


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.


Solution

  • 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.