Monday, October 16, 2017

Android: Android UI Background Image


Objective: 
The objective of this Android tutorial is to display background with an image. Refer the screen shots below.

Screenshots:
Background Image:





Instructions to setup:
1. Git clone the project and you should see the project \FirstApp downloaded
2. Now open the project in Android Studio
3. Press the keyboard – Shift + F10 to run the App, select the configured virtual device and click OK.

4. You can now see the output in the Android Emulator.

Source Code Explanation:
1. Finalize the background image.
Finalize the background image (usually of the size 540 X 960) and copy it to src\main\res\drawable. Here I copied the image named download.jpg

2. activity_main.xml (under \src\res\layout\)
1. Overall Layout is set as "RelativeLayout"
2. Background is set as @drawable/download (extension of the image i.e .jpg is required)

3. string.xml (under \src\res\values\)
Set the app name to “First Application”.

4. colors.xml (under \src\res\values\)
Change the colours in this colors.xml file to suit the background image.


No comments:

Post a Comment