Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
616 views
in Technique[技术] by (71.8m points)

android layout - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...