I'm Mihiran Rupasinghe. Today we'll see how you can layouts in android.
To create layouts first you have to create xml file in your layout folder.
1. click the button "Open wizard to help create a new Android XML file".
2. Select 'Layout' in Resource Type.
3. Select your project and give a suitable name (cannot start in capital).
4. Select your layout type for the root element (Linear Layout is recommended).
Now you have to create a class for your xml file in "src" folder.
In Superclass section select brows and type Activity and select "Activity - android.app". click OK.
Very important. When you create an Activity you must have to define it in manifest file like this.
We are almost done. Only thing we have to do now is set the layout to the class. First clean and build your project. Then the id of xml file will be added to R.java file. Open your class file. Inside Activity, type "onCreate" and press 'Ctrl' and 'space' together. Then select the first option, 'onCreate(Bundle savedInstanceState)'. And modify like below.
You are done !.
Most of the beginners is having this problem how to use layout appropriately. I'm going to show you how to use Linear Layout in applications. That is the most suitable way to use layouts.
Main Page Log in Page Registration Page
In here, all the layouts are done by using linear layouts. Its very simple. Technique is I have use Linear layouts (horizontal) inside of Linear layout (vertical). You can set the background like shown in below. "@drawable/background" means I have an image called 'background' in my drawable-hdpi folder. Sample code of Sign In page is shown below.
See you in the next Chapter.