Wednesday, February 1, 2017


Linear Layout

Linear Layout organizes elements along a single line. You specify whether that line is vertical or horizontal using android:orientation. Here is a sample Layout XML using Linear Layout. Change Orientation horizontal if you want to adjust widgets horizontally.

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="match_parent"
 android:layout_height="match_parent">

 <Button
 android:id="@+id/backbutton"
 android:text="Back"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" />

<TextView
 android:text="First Name"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" />

<EditText
 android:width="100px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:text="Last Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

 <EditText
android:width="100px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

Relative Layout

 RelativeLayout lays out elements based on their relationships with one another, and with the parent container. This is arguably the most complicated layout, and we need several properties to actually get the layout we want.

<RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingLeft="16dp"
 android:paddingRight="16dp" >

 <EditText
android:id="@+id/name"
 android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/reminder" />
 
<Spinner
 android:id="@+id/dates"
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_below="@id/name"
 android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/times" />

<Spinner
android:id="@id/times"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentRight="true" />

<Button
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/times"
android:layout_alignParentRight="true"
android:text="@string/done" />

</RelativeLayout>

13 comments:

  1. Nice article admin thanks for share your article keep share your knowledge i am waiting for your new post check nursing dresses boys t shirts kindly review and reply me

    ReplyDelete
  2. This is a notable guideline for both entrepreneurs and freelancers whose services are in demand! Great work! Thanks for sharing the info.
    Hire Dedicated Magento Developer
    Smarty Developers
    Hire Dedicated Developers
    Hire Dedicated Web Developers
    Hire Dedicated Opencart Developers

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. The growing market of Android mobile apps offers an Android App development Company to focus on the native applications development and games in the cellular dimension.

    ReplyDelete
  5. We are spearheaded in bringing new and innovative items and ideas to life. As one of the top Mobile App Development Company in Dubai we intend to assist you with distinguishing the dangers and openings related with the project and consequently bring to you the most recent mobile app development services. For More Info: Mobile App Development Company

    ReplyDelete
  6. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. gc hyip templates

    ReplyDelete
  7. WELL!!The thing I was searching from long time,now I get it.Thank you.We have one of the suitable tools that is WinDirStat for clean up your PC which will increase MS Windows operating system performance.

    ReplyDelete
  8. This is an best post. It is Really very informative concept.I like it and help me to development very well.

    Are you believing that a Mobile App Ideas is costly? The App Ideas is leading web and Mobile App development. We provide the best IT Services at best rates. Contact us now!

    ReplyDelete