[application] Splash Screen

PUJIN·2023년 7월 11일
0

코딩 - 프로젝트

목록 보기
3/13
post-thumbnail

splash screen


어플리케이션을 실행시 로고를 보여주고 지정된 시간이 지나면 사라지는 화면

  • 첫 화면을 보여주기 전까지 시간 확보 → 3초 이상 X
  • 어플리케이션을 각인 시키는 용도로 활용

1. build.gradle (Module:app)

  • 라이브러리 설정
dependencies {
    implementation 'androidx.core:core-splashscreen:1.0.1'
}

2. themes.xml

  • splash screen에 필요한 요소 구성
    • windowSplashScreenBackground : 배경 설정 (색상, 이미지 설정 가능)
    • windowSplashScreenAnimatedIcon : 사용할 아이콘 설정
    • windowSplashScreenAnimationDuration : 보여줄 시간 설정
      • 최대 1000ms
    • postSplashScreenTheme : splash screen 다음에 나올 화면 테마 설정
<style name="Theme.Highbally" parent="Base.Theme.Highbally" />

<style name="AppTheme.Splash" parent="Theme.SplashScreen">
	<item name="windowSplashScreenBackground">@color/white</item>
	<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">@mipmap/ic_launcher_highbally</item>
	<item name="windowSplashScreenAnimationDuration">1</item>
	<item name="postSplashScreenTheme">@style/Theme.Highbally</item>
</style>

3. AndroidManifest.xml

  • 첫 실행 acitivity의 테마를 splash screen 테마로 설정

4. 첫 화면 activity

  • installSplashScreen : splash screen 적용
    • setContentView 전에 코드 작성
class LoginMainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        installSplashScreen()

        setContentView(R.layout.activity_login_main)
    }
}

0개의 댓글

관련 채용 정보