I want my Android View’s background to be the logo on a white background.
I can make my View’s background white:
android:background="@color/colorWhite"
I can make my View’s background a PNG:
android:background="@drawable/logo"
But not both at the same time (Attribute "android:background" was already specified).
If I write only @drawable/logo then the logo is drawn on a black background.
How to do? Preferably without adding a layer of view.
SOLUTION: I used Avinazz’s first suggestion, and here is the code:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@color/white"/>
<item>
<bitmap android:src="@drawable/logo"
android:gravity="center" />
</item>
</layer-list>
With strings.xml containing <color name="white">#FFFFFF</color>.
Several possibilities:
1) Use Layer drawables or overlay two images in android to set an imageview
2) Tweak your xml to have container background to have white backgroud, and child with your desired image with transperancy.
3) Edit the image to have white background.