3

I have LinearLayout, and I have png that I used as tiles - but i want also that the color behind it will be white.

Is that possible?

My code is:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/LinearMain" android:background="@drawable/bcktiles">

and the drawable is:

    <?xml version="1.0" encoding="utf-8"?>
 <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/bgsite" android:tileMode="repeat">
    </bitmap>

I dont know where to put #fff

Thanks

Himberjack
  • 5,682
  • 18
  • 71
  • 115

2 Answers2

6

You can also create a composite drawable by doing:

drawable/composite.xml:

<layer-list 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="color drawable" />
    <item android:drawable="drawable 1..." />
</layer-list>

And for your color, you can create a shape drawable:

<shape 
xmlns:android="http://schemas.android.com/apk/res/android">
  <solid android:color="color" />
</shape>
Steve Pomeroy
  • 10,071
  • 6
  • 34
  • 37
  • This is a good choice, just watch out for [disappearing padding values](http://stackoverflow.com/questions/6104677/transitiondrawable-doesnt-account-for-padding/6105149#6105149). – dmon Jun 08 '11 at 20:26
  • I have it well on the eclipse preview screen but when laucnhing on XOOM i see only white! – Himberjack Jun 08 '11 at 20:29
  • You may be bitten by this bug: http://code.google.com/p/android/issues/detail?id=15340 – Steve Pomeroy Jun 08 '11 at 20:43
0

In your LinearLayout, you'd want to use android:background="@color/myColor" if you're referencing a color resource. You can also just put android:background="#FFFFFFFF" if you don't want to store it as a resource.

BigFwoosh
  • 1,197
  • 10
  • 17
  • but then im replacing the drawable reference! – Himberjack Jun 08 '11 at 20:21
  • You've only really got one spot to put a background in a LinearLayout, so you'd have to choose between a color or tiles. Why not use a RelativeLayout, set the background to your color, and then put an ImageView in it that is set to FILL_PARENT that shows your tiles? That way, you can still put other views overtop of the tiles. – BigFwoosh Jun 08 '11 at 20:25