Android Studio: UI Layout

Android

Bismilahhirahmanirrahim ~ In The Name Of Allah The Most Gracious and The Most Merciful

Layout Attributes

android:id

ID which is uniquely identify the views


android:layout_width

width for layout


android:layout_height

height for layout


android:layout_marginTop

extra space on the top of side of layout


android:layout_marginBottom

extra space on the bottom side of layout


android:layout_marginRight

extra space on the right side of layout


android:layout_marginLeft

extra space on the left side of layout


android:layout_gravity

specifies how child Views is positioned


android:layout_weight

specifies how much of the extra space in the layout should be allocated to the View


android:layout_x

specifies the x-coordinate of the layout


android:layout_y

specifies the y-coordinate of the layout


android:paddingLeft

left padding filled for the layout


android:paddingRight

right padding filled for the layout


android:paddingTop

top padding filled for the layout


android:paddingBottom

bottom padding filled for the layout



Constant to set height and width by using:

  • android:layout_width=wrap_content
  • android:layout_width=wrap_content

What is view? 

I’m not really sure how to explain.. i just like to assign unique variable that called ‘view object’..you will find just like this android:id=”@+id/register_button”

  • ‘@’ the beginning of string indicates that the XML parser should parse and expand the rest of ID string and identify it as an ID resourse
  • ‘+’ means that this is a new resource name that must be created and added to our resources. Example how to create an instance of object and capture it from layout.. it just like to declare it.. you can write like this..
  • Button register_button = (Button) findViewById(R.id.register_button); 

Layout Type

Linear Layout

LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally.

Relative Layout

RelativeLayout is a view group that displays child views in relative positions.

Table Layout

TableLayout is a view that groups views into rows and columns.

Absolute Layout

AbsoluteLayout enables you to specify the exact location of its children.

Frame Layout

The FrameLayout is a placeholder on screen that you can use to display a single view.

List View

ListView is a view group that displays a list of scrollable items.

Grid View

GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid.

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *