Wednesday 14 November 2012

Drag & drop elements in LAYOUT





Today we are discussing about the drag & drop elements in LAYOUT.The layout elements in ANDROID are given bellow.




Linear Layout


  • It is a view group which aligns all the children in a single directrion,ie.horizontally or vertically.

  • The developer can specify the layout direction by using android:orientation attribute.

  • There are 2 types of linear layout.They are linear layout(horizontally) and linear layout(vertically).
  • The default code is given bellow.

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
    </LinearLayout>



Relative Layout


  • Relative layout is a layout where posotions of the children can be described related to to the parent or each other.
  • Relative layout whose height can be set to WRAP_CONTENT and ALIGN_PARENT_BOTTOM for child.
  • The default code is given bellow.

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </RelativeLayout>


FrameLayout


  • Frame Layout is designed to use block out an area on the screen for displaying a single item.

  • Frame Layout is mainly used for holding a single child view.
  • The default code is given bellow.

    <FrameLayout
        android:id="@+id/frameLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </FrameLayout>

Fragments


  • Fragments in layout represents portion or behaviour of user interface in an Activity.

  • We can combine multiple fragments in a single activity to build a multi pane user interface.

  • Fragments can reuse in multiple activity.

Table Layout
  • Table layout arranges its chidren elements into columns and rows.

  • A Table Layout consist of number of rows and columns.
  • It does not show the table border.
  • The default code is given bellow.
    <TableLayout
            android:id="@+id/tableLayout1"
              android:layout_width="match_parent"
                android:layout_height="wrap_content" >
                    <TableRow
                          android:id="@+id/tableRow1"
                            android:layout_width="wrap_content"
                              android:layout_height="wrap_content" >
                            </TableRow>
                                <TableRow
                                      android:id="@+id/tableRow2"
                                        android:layout_width="wrap_content"
                                          android:layout_height="wrap_content" >
                                        </TableRow>
                                            <TableRow
                                                  android:id="@+id/tableRow3"
                                                    android:layout_width="wrap_content"
                                                      android:layout_height="wrap_content" >
                                                    </TableRow>
                                                        <TableRow
                                                              android:id="@+id/tableRow4"
                                                                android:layout_width="wrap_content"
                                                                  android:layout_height="wrap_content" >
                                                                </TableRow>
                                                              </TableLayout>
                                                              
                                                            Table Row


                                                            • Table Row arranges its children elements horizontally.
                                                            • It is always used as a child of Table Layout.
                                                            • The default code is given bellow.

                                                                <TableRow
                                                                    android:id="@+id/tableRow1"
                                                                    android:layout_width="match_parent"
                                                                    android:layout_height="wrap_content" >
                                                                </TableRow>


                                                            0 comments: