Monday, October 14, 2013

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;

No comments:

Post a Comment