
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
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;
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
tools:context=".MainActivity" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"/>
4. Run your application. The image will be applied as background for this layout.

0 comments
Post A Comment