简体   繁体   English

Android应用程序:背景颜色的背景图像

[英]Android Application : Background Image over Background Color

I am new to android development and am developing my first android application. 我是Android开发的新手,正在开发我的第一个Android应用程序。 I have the background color of the View set in the layout's xml as follows. 我在布局的xml中设置了View的背景颜色,如下所示。

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. 提前致谢。

You can use an ImageView with a background color: 您可以使用具有背景颜色的ImageView:

<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. 另一个选项是在布局的根元素中设置背景颜色,并将src保留在ImageView中。

I'm using AppCompatImageView . 我正在使用AppCompatImageView In this background color can be set using the below property. 在此背景中,可以使用以下属性设置颜色。

android:backgroundTint="@color/colorPrimary"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM