0% found this document useful (0 votes)
24 views

Layouts in Android: The Most Commonly Used Layouts Are - Linearlayout - Tablelayout - Relativelayout - Framelayout

The document discusses common layouts in Android such as LinearLayout, TableLayout, RelativeLayout, and FrameLayout. It provides details on their properties and how to create them in XML and Java files. Examples are given of creating a LinearLayout and TableLayout with code snippets and discussion of their outputs.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Layouts in Android: The Most Commonly Used Layouts Are - Linearlayout - Tablelayout - Relativelayout - Framelayout

The document discusses common layouts in Android such as LinearLayout, TableLayout, RelativeLayout, and FrameLayout. It provides details on their properties and how to create them in XML and Java files. Examples are given of creating a LinearLayout and TableLayout with code snippets and discussion of their outputs.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

LAYOUTS IN ANDROID

The most commonly used Layouts are LinearLayout TableLayout RelativeLayout Framelayout

LinearLayout
Aligns all children in a single direction vertically or horizontally Can be defined by orientation attribute

TableLayout
Positions its children into rows and columns do not display border lines for their rows, columns, or cells

RelativeLayout
lets child views specify their position relative to the parent view or to each other (specified by ID)

FrameLayout
Layout that acts as a view frame to display a single object.

Creating layout using Linearlayout(xml file)

Creating layout using Linearlayout(java file)


Button b1=(Button)findViewById(R.id.button1); final CheckBox ck=(CheckBox)findViewById(R.id.checkBox1); final TextView tv=(TextView)findViewById(R.id.textView1);

b1.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { // TODO Auto-generated method stub if(ck.isChecked()) { String s="THANKS"; tv.setText(s); }
else { String s1="Please check the checkbox"; tv.setText(s1); } } });

Output of LinearLayout

Creating TableLayout(xml file)


Graphical representation of TableLayout in xml file

We can look the hierarchyof the table layout in the outline window

Output of the TableLayout

The output of the above TableLayout is as shown

You might also like