Go to values/style or theme and paste this code:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.BookApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
<!-- style niche jeta dekha jacce eta dilei hobe .. karon uporer likha gulo already style er moddhe thakbei .. ba ei page e thakbei -->
<style name="splashscreen" parent="Theme.MaterialComponents.DayNight.NoActionBar">
</style>
</resources>
Android Manifest.xml code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bookapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.BookApp">
<!-- eikhane splashscreen activity ta add korte hobe tar age obossoi splash screen ekti activity creat krte hobe .-->
<activity android:name=".splashscreen"
android:theme="@style/splashscreen"
android:noHistory="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- upore jei comment ase sei comment theke ei comment porjonto notun code-->
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
before the manfiest code submit ...(you need to creat splashscreen activity)
splashscreen.kt
package com.example.bookapp
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import java.lang.Exception
class splashscreen : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splashscreen)
val background = object : Thread() {
override fun run() {
try {
Thread.sleep(5000)
val intent = Intent(baseContext, MainActivity::class.java)
startActivity(intent)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
background.start()
}
}
layout/activity_splashscreen.xml code here:
package com.example.bookapp
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import java.lang.Exception
class splashscreen : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splashscreen)
val background = object : Thread() {
override fun run() {
try {
Thread.sleep(5000)
val intent = Intent(baseContext, MainActivity::class.java)
startActivity(intent)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
background.start()
}
}
0 Comments