How To Set Background Image in Android Application


How To Set Background Image in Android Application


It's quite simple to set background image for your android application. Below I have an example code for this as well. Now, just follow the steps..

1. Create a new android application in Eclipse. (click here if you need some help)


2. Copy your image file to /res/drawable directory. You will need to access the worksplace file directory directly. This should be in your C Drive eg. C:\users\<username>\workspace\<appname>\res\drawable-mdpi
This directory should already have your app icon image file in it.
  
3. Open your  layout xml file activity_main.xml
    and add below line;  


android:background="@drawable/bg"
 Here 'bg' is the name of the image without extension

So final layout file will look like;

Comments

Popular posts from this blog

W3Schools SQL Test Questions and Answers

How to migrate from Twitter API version 1 to version 1.1

Waltzing with Bears : Managing Risk on Software Projects by Tom Demarco Chapters 1 to 4 Reflection