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.

Amyth
  • 32,527
  • 26
  • 93
  • 135

2 Answers2

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.

Iñigo
  • 12,723
  • 2
  • 31
  • 31
0

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

android:backgroundTint="@color/colorPrimary"
Shree Harsha S
  • 665
  • 7
  • 14