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

5

The document contains two XML layout files defining user interface elements and associated Java code to display them. The first layout uses a linear layout and defines text views for name, age, and mobile number. The second uses an absolute layout and defines the same text views at specific coordinates with additional styling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

5

The document contains two XML layout files defining user interface elements and associated Java code to display them. The first layout uses a linear layout and defines text views for name, age, and mobile number. The second uses an absolute layout and defines the same text views at specific coordinates with additional styling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1)

<?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:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:orientation="vertical"
tools:context=".MainActivity">

<TextView
android:id="@+id/student_name"
android:layout_width="wrap_content
android:layout_height="wrap_content"
android:text="Name:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age:" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile Number:" />
</LinearLayout>
Java code:
package com.blogspot.codingatharva.firstapp;
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)
<?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:paddingLeft="16dp"
android:paddingTop="16dp"
android:paddingRight="16dp"
tools:context=".MainActivity">
<TextView
android:id="@+id/student_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="125dp"
android:layout_y="280dp"
android:text="Name:"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="125dp"
android:layout_y="304dp"
android:text="Age:"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="125dp"
android:layout_y="328dp"
android:text="Mobile Number:"
android:textColor="#86AD33"
android:textSize="20dp"
android:textStyle="bold" />
</AbsoluteLayout>
Java code:
package com.blogspot.codingatharva.firstapp;
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);
}}

You might also like