[go: up one dir, main page]

0% found this document useful (0 votes)
9 views2 pages

Program 6R

The document contains the XML layout files for an Android application, including a main screen and a splash screen, as well as Kotlin code for the main and splash activities. The splash screen displays a welcome message and an image for 3 seconds before transitioning to the main screen. Additionally, there is a themes.xml file defining the app's theme style.

Uploaded by

Siva Ranjini H
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)
9 views2 pages

Program 6R

The document contains the XML layout files for an Android application, including a main screen and a splash screen, as well as Kotlin code for the main and splash activities. The splash screen displays a welcome message and an image for 3 seconds before transitioning to the main screen. Additionally, there is a themes.xml file defining the app's theme style.

Uploaded by

Siva Ranjini H
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/ 2

Program 5:

activity_main.xml:
<?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">

<TextView
android:text="This is Main Screen"
android:layout_centerInParent="true"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

activity_splash.xml:

<?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:background="#6200EE">

<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@mipmap/ic_launcher" />

<TextView
android:layout_marginTop="20dp"
android:text="Welcome to My App!"
android:textSize="24sp"
android:textColor="#FFFFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>

MainActivity.kt:
package com.example.splash

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
SplashActivity.kt:

package com.example.splash

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AppCompatActivity

class SplashActivity : AppCompatActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)

Handler(Looper.getMainLooper()).postDelayed({
startActivity(Intent(this, MainActivity::class.java))
finish()
}, 3000) // 3 seconds
}
}

Themes.xml:

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


<resources>

<style name="Theme.Splash" parent="Theme.AppCompat.DayNight" />


</resources>

You might also like