Android App: Background Image by Background Color

I am new to Android development and developing my first Android app. I have the background color in the View in the xml layout 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 above this image.

Is there a way that I can use both the background color and the background image in the same layout.

Thanks at Advance.

+7
source share
2 answers

You can use ImageView with 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 save the src in your ImageView.

+11
source

I am using AppCompatImageView . Against this background, the color can be set using the property below.

 android:backgroundTint="@color/colorPrimary" 
0
source

All Articles