Skip to content

Commit 9520878

Browse files
committed
add splash screen
1 parent 2d5ac26 commit 9520878

5 files changed

Lines changed: 77 additions & 7 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@
1313
android:supportsRtl="true"
1414
android:theme="@style/Theme.GithubUser"
1515
tools:targetApi="31">
16+
<activity
17+
android:name=".SplashScreenActivity"
18+
android:exported="true"
19+
android:theme="@style/Theme.SplashScreenTheme">
20+
<intent-filter>
21+
<action android:name="android.intent.action.MAIN" />
22+
23+
<category android:name="android.intent.category.LAUNCHER" />
24+
</intent-filter>
25+
</activity>
1626
<activity
1727
android:name=".ui.detail.DetailUserActivity"
1828
android:exported="false" />
1929
<activity
2030
android:name=".ui.main.MainActivity"
21-
android:exported="true">
22-
<intent-filter>
23-
<action android:name="android.intent.action.MAIN" />
24-
25-
<category android:name="android.intent.category.LAUNCHER" />
26-
</intent-filter>
27-
</activity>
31+
android:exported="true"/>
2832
</application>
2933

3034
</manifest>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.riyandifirman.githubuser
2+
3+
import android.content.Intent
4+
import androidx.appcompat.app.AppCompatActivity
5+
import android.os.Bundle
6+
import com.riyandifirman.githubuser.databinding.ActivitySplashScreenBinding
7+
import com.riyandifirman.githubuser.ui.main.MainActivity
8+
9+
class SplashScreenActivity : AppCompatActivity() {
10+
// Inisialisasi binding
11+
private lateinit var binding: ActivitySplashScreenBinding
12+
13+
override fun onCreate(savedInstanceState: Bundle?) {
14+
super.onCreate(savedInstanceState)
15+
16+
// Inisialisasi binding
17+
binding = ActivitySplashScreenBinding.inflate(layoutInflater)
18+
setContentView(binding.root)
19+
20+
// Animasi
21+
var image = binding.ivSplashScreenIcon
22+
image.alpha = 0f
23+
// Durasi animasi
24+
image.animate().setDuration(2000).alpha(1f).withEndAction {
25+
// Intent
26+
val intent = Intent(this, MainActivity::class.java)
27+
startActivity(intent)
28+
// Animasi
29+
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
30+
finish()
31+
}
32+
33+
}
34+
}
28.3 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:background="@color/white"
8+
tools:context=".SplashScreenActivity">
9+
10+
<ImageView
11+
android:id="@+id/iv_splash_screen_icon"
12+
android:layout_width="200dp"
13+
android:layout_height="200dp"
14+
app:layout_constraintBottom_toBottomOf="parent"
15+
app:layout_constraintEnd_toEndOf="parent"
16+
app:layout_constraintStart_toStartOf="parent"
17+
app:layout_constraintTop_toTopOf="parent"
18+
app:srcCompat="@drawable/ic_splash_screen" />
19+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/themes.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,17 @@
1313
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
1414
<!-- Customize your theme here. -->
1515
</style>
16+
<style name="Theme.SplashScreenTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
17+
<!-- Primary brand color. -->
18+
<item name="colorPrimary">@color/white</item>
19+
<item name="colorPrimaryVariant">@color/white</item>
20+
<item name="colorOnPrimary">@color/white</item>
21+
<!-- Secondary brand color. -->
22+
<item name="colorSecondary">@color/teal_200</item>
23+
<item name="colorSecondaryVariant">@color/teal_700</item>
24+
<item name="colorOnSecondary">@color/black</item>
25+
<!-- Status bar color. -->
26+
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
27+
<!-- Customize your theme here. -->
28+
</style>
1629
</resources>

0 commit comments

Comments
 (0)