BigCAT41
BigCAT41

Reputation: 93

Android picture in background

Hi, I have no clue how to go about this but I want to put in the background of all the screens a picture instead of it being black. How would I do this through XML or the Java code and what kind of layout would I have to use if it is in XML?

Upvotes: 2

Views: 378

Answers (3)

richman64
richman64

Reputation: 93

You can use the following attribute on some ViewGroup layout objects (like LinearLayout and RelativeLayout):

android:background="@drawable/YOUR_IMAGE_RESOURCE_HERE"

Make sure to set your layout_height and layout_width to fill_parent on the root View and set this attribute on it if you want the background to fill the screen.

Upvotes: 1

Mangusto
Mangusto

Reputation: 1505

Just add android:background="@drawable/your_image"to the root layout of your XML. It will be stretched to fill all the screen, so if your image doesn't perfectly match the screen size you'll need to create another BitmapDrawable XML in which you declare the properties of the image.

Upvotes: 2

Kurtis Nusbaum
Kurtis Nusbaum

Reputation: 30825

First you would create a style with the background set to your image. Then you would use the android:theme attribute on your application to apply the style to all the activities in your application. For more information, please read Style and Themes.

Upvotes: 0

Related Questions