Android Application : Background Image over Background Color
Asked Answered
A

2

9

I am new to android development and am developing my first android application. I have the background color of the View set in the layout's xml as follows.

android:background="@+color/bgColor"

Now, i have a full sized transparent background image that i want to lay over the background and then other Elements over that image.

is there a way i can use both background color and background image in the same layout.

Thanks in Advance.

Ahern answered 15/7, 2012 at 8:7 Comment(0)
H
15

You can use an ImageView with a background color:

<ImageView
    layout_width="match_parent"
    layout_height="match_parent"
    src="@drawable/myImage"
    background="@color/myBgColor" />

Another option is to set the background color in the root element of your layout, and keep the src in your ImageView.

Hormonal answered 15/7, 2012 at 8:14 Comment(0)
E
0

I'm using AppCompatImageView. In this background color can be set using the below property.

android:backgroundTint="@color/colorPrimary"
Eventful answered 1/1, 2017 at 14:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.