Practical No 5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Practical No 5

1. Write a program to place Name, Age and mobile number linearly

(Vertical) on the display screen using Linear layout.


<?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:gravity="center"
android:orientation="vertical" tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Aditya Jadhav"
android:layout_marginBottom="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="19years"
android:layout_marginBottom="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="121334213xxxx"
/>

</LinearLayout>
1. Write a program to place Name, Age and mobile number centrally on the display screen using
Absolute layout.
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
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:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">

<TextView
android:layout_x="150dp"
android:layout_y="300dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aditya Jadhav"
/>
<TextView
android:layout_x="150dp"
android:layout_y="350dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19years"
/>
<TextView
android:layout_x="150dp"
android:layout_y="390dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="121334213xxxx"
/>

</AbsoluteLayout>

Output:-
1. Write a program to place Name, Age and mobile number centrally on the display screen using
Absolute layout.
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
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:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">

<TextView
android:layout_x="150dp"
android:layout_y="300dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aditya Jadhav"
/>
<TextView
android:layout_x="150dp"
android:layout_y="350dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19years"
/>
<TextView
android:layout_x="150dp"
android:layout_y="390dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="121334213xxxx"
/>

</AbsoluteLayout>

Output:-

You might also like