This is simple step by step tutorial for “How to set background image in android game”. Today we will learn step by step instructions to set background of your android game. We will use android studio IDE for creating a simple project.  The very first step is create a simple project.

How to set background image in android game

Step (2) How to set background image in android game

  Configure your project, this is the step where we need to fill application name. The second entry is company domain. if you have domain like wikistack.com, we can fill this name. However if we fill like com.wikistack it should be unique.

How to set background image in android game

Step 3 ( Target Your Android device )

nex1

Step 3 ( Add an Activity to mobile )

In this step select blank activity.

blank andoid activity

Step 4 (  Customize the Activity)

This the last step. The default activity class name is MainActivity. MainActivity is a Java class.

nex3

Step 4 ( Set Background )

At this stage we have ready to build and run project. android studio organize the project into an certain structure.  We can see the project structures on left side of project sub section of android studio. Now we have to follow following steps to set background.

  • Prepare your background image , say it is background.png.
  • Copy the background image ( background.png).
  • Paste into the drawable ( This is inside the  project structure see below image)

How to set background image in android game

Now we have our background image in drawable. Open activity_main.xml file and paste following text.

android:background=”@drawable/background”

change activity_main.xml to set background

After completing this wen we run the program we can observer the game background.
Reference:
http://developer.android.com/develop/index.html