Reputation: 883
I'm just starting out in Android and was making a splash screen. I tried to change the default background colour to grey, but apparently I can't use the same attribute twice. How can I add a background image and change the background colour? Thanks.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/reddit_alien"
android:background="@color/grey"
>
</LinearLayout>
Upvotes: 0
Views: 175
Reputation: 9284
One way to do this, which would be to use 2 layouts.. The outer one having a background of the color and the inner one having the image as the background.
Alternatively you could use a layer list drawable resource file in xml which defines one layer as being the background color and another as the background image. see here: http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList
Upvotes: 3
Reputation: 974
No that's not possible to declare same property twice. Either she them image as background or color.If you want to set the color and background image then create two views. Set the bottom view background to color or image and set the top view background to color or image.
Upvotes: 0