0% found this document useful (0 votes)
32 views9 pages

Mad Exp4&5

The document discusses two Android programs: 1) Displays name, age, mobile number vertically using LinearLayout. 2) Displays the same using AbsoluteLayout by specifying pixel positions.

Uploaded by

HARSH MAGHNANI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views9 pages

Mad Exp4&5

The document discusses two Android programs: 1) Displays name, age, mobile number vertically using LinearLayout. 2) Displays the same using AbsoluteLayout by specifying pixel positions.

Uploaded by

HARSH MAGHNANI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Practical 4

1. Write a program to display hello world.

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

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="320dp"
android:text="Hello world!"
android:textSize="20dp"
android:layout_marginLeft="140dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Created By Deepesh Navani"
android:textStyle="bold"
android:textSize="20dp"
android:layout_marginLeft="70dp"
android:layout_marginTop="10dp"
/>
</LinearLayout>

Main.java:
package com.example.myapplication;
import
androidx.appcompat.app.AppCompatActivity;
import
android.os.Bundle;
public class MainActivity extends AppCompatActivity
{

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
2. Write a program to print student name and
percentage.

Main.xml:
<?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" tools:context=".MainActivity"
android:orientation="vertical" android:layout_marginLeft="80dp"
android:layout_marginTop="350dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Deeepesh Navani"
android:textStyle="bold"
android:textSize="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Percentage: 80%"
android:textStyle="bold"
android:textSize="20dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Created by deepesh navani_15"
android:textStyle="bold"
android:textSize="20dp"
/>

</LinearLayout>

Main.java:
package com.example.a4_2;
import
androidx.appcompat.app.AppCompatActivity;
import
android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); }
}
Output:-
Practical 5
1.Write a program to place Name, Age and mobile number linearly (Vertical) on the display screen
using Linear layout.

Main.xml:
<?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" tools:context=".MainActivity"
android:orientation="vertical" android:layout_margin="70dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Deepesh"
android:textStyle="bold"
android:textSize="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age: 18"
android:textStyle="bold"
android:textSize="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile no-: 93093xxxxx"
android:textStyle="bold"
android:textSize="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Created by deepesh navani Roll
no:15" android:textStyle="bold"
android:textSize="20dp"
/>

</LinearLayout>
Main.java:
package com.example.a5_1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); }
}
2.write a program to display name, age, mobile no on screen using absolute layout.

Main.xml:
<?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" tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Deepesh Navani"
android:textStyle="bold"
android:textSize="18dp"
android:layout_x="100dp"
android:layout_y="50dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age: 18"
android:textStyle="bold"
android:textSize="18dp"
android:layout_x="100dp"
android:layout_y="80dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile no:- 93093xxxxx"
android:textStyle="bold"
android:textSize="18dp"
android:layout_x="100dp"
android:layout_y="110dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="140dp"
android:text="Created by Deepesh Navani"
android:textSize="18dp"
android:textStyle="bold"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="170dp"
android:text="Roll no- 15"
android:textSize="18dp"
android:textStyle="bold"
/>
<AbsoluteLayout/>

Main.java:
package com.example.a5_1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); }
}

Output:-

You might also like