How To Create Linear Layout in android

Published Date: 2nd March, 2016 at 8:41 pm
   

Hey guys in this android tutorial we will  be discussing about layouts in android. There are basically 3 layouts in android named Linear layout, Relative layout and table layout. Layouts actually define the visual structure of user interface. Android allows us to create a layout to design user interface and we can easily create a layout using xml file (We can also create a layout using java programming).

 

Linear Layout in android

There are two types of linear layouts 1. Horizontal Linear Layout and 2. Vertical Linear Layout.

Suppose that our default layout is Vertical Linear Layout so when you add some Form Widgets like button, text view etc. then it will be arranged in the stack fashion! though there is a space for to add other widgets but it will not allow you to add it.

Read Also- images for whatsapp

You can use the both of the layout at the same time! like your default layout is Vertical Linear layout then simply add horizontal linear layout inside it and you will be able to place the widgets side by side like this.

Here is an xml code for the same.

http://schemas.android.com/apk/res/android”
    android:layout_width=”fill_parent”
    android:layout_height=”fill_parent”
    android:orientation=”vertical” > 
            android:layout_width=”match_parent”
        android:layout_height=”wrap_content” > 
                    android:id=”@+id/button1″
            android:layout_width=”wrap_content”
            android:layout_height=”wrap_content”
            android:text=”Button” /> 
                    android:id=”@+id/button2″
            android:layout_width=”wrap_content”
            android:layout_height=”wrap_content”
            android:text=”Button” /> 
                    android:id=”@+id/button3″
            android:layout_width=”wrap_content”
            android:layout_height=”wrap_content”
            android:text=”Button” /> 
                    android:id=”@+id/button4″
            android:layout_width=”wrap_content”
            android:layout_height=”wrap_content”
            android:text=”Button” />

You can also do the reverse thing too 

Relative Layout in android

Relative layout in android is most popular and its mostly being using because it works fine in both of the views portrait and landscape. that’s why it’s mostly being used. You can also use grid and table layout to design your application well.

So guys here were the tutorial about creating layout in android.If you have some question in your mind then comment here,i will reply for sure.Cheers @!!!!

Write a Comment

loader