Layout XML Code (Cont.)

LinearLayout class
This class arranges its children in a single column or a single row. There are several other layouts, which can be combined hierarchically to create complex screen layouts. This code defines an orientation, width, and height for the entire scope of the layout.

android:orientation="vertical"
This attribute could include the following values:

  • horizontal, which has the views get stacked horizontally such as:
  view1  view2  view3  ...
  • vertical, which has the views get stacked vertically such as:
      view1
      view2
      view3
      ...
android:layout_width="fill_parent"
It forces the view to expand to take up as much space as is available within the layout element it has been placed in. Setting a top-level layout to fill_parent will take up the whole screen. For example, the top figure is the button width having fill_parent value and the middle one is the button height having fill_parent value.

android:layout_height="wrap_content"
Setting a view’s size to wrap_content will force it to expand only far enough to contain the values it contains. For example, the bottom figure is both button width and height having wrap_content value.

TextView class
This class displays text to the user.






HelloWorld/app/src/main/res/layout/activity_main.xml
<LinearLayout
  xmlns:android            = "http://schemas.android.com/apk/res/android"
  android:orientation      = "vertical"
  android:layout_width     = "fill_parent"
  android:layout_height    = "fill_parent"
  android:weightSum        = "1"
  android:gravity          = "center">
  <TextView
    android:layout_width   = "wrap_content"
    android:layout_height  = "wrap_content"
    android:textAppearance = "?android:attr/textAppearanceLarge"
    android:text           = "Hello, your name:"
    android:layout_weight  = "0.07"
    android:textStyle      = "bold" />
  <EditText
    android:layout_width   = "216dp"
    android:layout_height  = "wrap_content"
    android:id             = "@+id/name" />
  <Button
    android:layout_width   = "wrap_content"
    android:layout_height  = "wrap_content"
    android:text           = "@string/next_page"
    android:id             = "@+id/next" />
</LinearLayout>




      Alright guys, we all need to dig deep for the second half of the game.    
      Go out there and give a hundred and ten percent and bring home a win!