Lab 1
Lab 1
1. LinearLayout example
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/mylayout"
tools:context=".MainActivity">
<EditText
android:id="@+id/name"
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="enter your name"
android:textSize="26dp"/>
<EditText
android:id="@+id/fname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Father Name"
android:textSize="26dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Mother Name"
android:id="@+id/mom"
android:textSize="26dp"/>
<TextView
android:layout_width="151dp"
android:layout_height="34dp"
android:background="#E8EAB0"
android:text="Gender"
android:textAllCaps="true"
android:textColor="#FC0505"
android:textStyle="italic"
android:textSize="26dp"/>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:layout_width="125dp"
android:layout_height="wrap_content"
android:background="#EEF6E7"
android:text="Male"
android:textSize="26dp"/>
<RadioButton
android:id="@+id/backgroung"
android:layout_width="146dp"
android:layout_height="wrap_content"
android:background="#EEF6E7"
android:text="Female" />
</RadioGroup>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="my button"
android:textSize="26dp"/>
</LinearLayout>
2. RelativeLayout Example
<?xml version="1.0" encoding="utf-8" ?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:id="@+id/firstName"
android:text="First Name"
android:textSize="18sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/backbutton" />
<TextView
android:id="@+id/editFirstName"
android:text="Gebregziabher"
android:textSize="18sp"
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/firstName"
android:layout_below="@id/backbutton"/>
<TextView
android:id="@+id/editLastName"
android:text=" Kebad"
android:textSize="18sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/lastName"
android:layout_toRightOf="@+id/lastName"
android:layout_toEndOf="@+id/lastName" />
<TextView
android:id="@+id/lastName"
android:text="Last Name"
android:textSize="18sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:layout_below="@+id/firstName"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginRight="10dp"
android:layout_marginLeft="40dp"
android:layout_marginStart="40dp" />
<Button
android:id="@+id/next"
android:text="Next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editLastName"
android:layout_alignLeft="@+id/editLastName"
android:layout_alignStart="@+id/editLastName"
android:layout_marginTop="37dp" />
</RelativeLayout>
3. TableLayout Example
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*">
<TableRow>
<TextView
android:layout_span="3"
android:text="I am the only text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="30sp"
/>
</TableRow>
<TableRow>
<TextView
android:layout_column="0"
android:text="First text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_column="1"
android:text="second text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_column="2"
android:text="third text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_column="3"
android:text="third text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>