Add a Background Image to An Activity in Android Studio

Add a Repeating Background Image to an Activity in Android Studio

First, locate a repeating background image. I have used the coins image below.

Repeating Background Image

Repeating Background Image

I used the copy command to copy the image off of my desktop (cmd or cntrl + c), and then right clicked on my drawable folder in Android studio, and selected paste. The image was copied into my project.

Next, I right clicked the drawable folder and created a new drawable resource.

New XML Resource

New XML Resource

I named the file repeatingbackground. I pressed OK.

Name the File

Name the File

Drawable Asset XML Code

Drawable Asset XML Code

I placed the above code in the file. @drawable/coins is referring to coins.png, which is the repeating image I copied into the project.

Add the Image to the Activity

Add the Image to the Activity

I opened my activity_change.xml from the res/layout folder and added the android:background attribute.

Repeating Background Image

Repeating Background Image

And there is the result!

Share:

Facebooktwittergoogle_plusredditpinterestlinkedinmail

profcodegirl