9. activity_main.xml (UI for MainActivity)

3. activity_main.xml (UI for MainActivity)

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:gravity="center"

    android:padding="20dp">

 

    <!-- Welcome Text -->

    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Welcome to My Simple App"

        android:textSize="20sp"

        android:textStyle="bold"

        android:paddingBottom="20dp"/>

 

    <!-- Button to navigate to the second screen -->

    <Button

        android:id="@+id/btnNavigate"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Go to Second Screen"/>

</LinearLayout>

What this does:

  • Displays a welcome message.
  • Has a button to go to the second screen.

 

4. activity_second.xml (UI for SecondActivity)

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:gravity="center"

    android:padding="20dp">

 

    <!-- Message for Second Screen -->

    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="This is the Second Screen!"

        android:textSize="20sp"

        android:textStyle="bold"/>

</LinearLayout>

What this does:

  • Displays a message on the second screen.