Friday, 11 March 2016

Adding Background Image to your application Netbeans

1. Create a new android application in Netbeans.
2. Copy your image file to /res/drawable directory
(Note: Name of image file should be in small letter)



3 Open main.xml file and add following line to it.

        android:background="@drawable/hd_bg"

Here "hd_bg" is image file name without extension.
Your main.xml file should look like this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:background="@drawable/hd_bg"
>
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Hello World, MainActivity"
    />
</LinearLayout>
Save and run application.



No comments:

Post a Comment