Splash 화면 구성하기



reference: 

https://android.jlelse.eu/the-complete-android-splash-screen-guide-c7db82bce565




 방법

 1. Launcher Theme (The good)

  1. 2. Launcher Theme with a Dedicated Splash Activity (The okay)
  2. 3. Timers (The bad)
  3. 4. Smart Timers (The ugly)


 Launcher Theme

Activity가 onCreate() 조차도 불러지기 전, 

즉, 메모리에 앱이 올라가는 과정에다가 사용자가 지정한 화면을 넣는다는 것이 키포인트입니다.

앱 theme의 attributes 중에 windowBackground을 override 하는 것인데요, 

그 말인 즉, windowBackground라는 친구는 말그대로 activity 화면 뒤의 백그라운드를 뜻하는 것 같습니다.

windowBackground 위에 activity의 layout이 그려지기 때문에, 

그 백그라운드에 내가 원하는 화면을 그려넣겠다는 의미죠.

아주 단순합니다.


 Override windowBackground


<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Your AppTheme or other themes/styles here -->
<!-- The launcher theme. It sets the main window background to the launch_screen drawable -->
<style name=”AppTheme.Launcher”>
<item name=”android:windowBackground”>@drawable/launch_screen</item>
<!-- Optional, on Android 5+ you can modify the colorPrimaryDark color to match the windowBackground color for further branding-->
<!-- <item name="colorPrimaryDark">@android:color/white</item> -->
</style>
</resources>
view rawstyles.xml hosted with ❤ by GitHub

위 예제와 같이, AppTheme의 windowBackground를 지정해주고,

launcher activity의 테마를 위 테마로 지정해주기만 하면됩니다.

launch_screen의 이미지가 표시됩니다.



Conclusion


일반적이고 naive한 splash 구성 방법은 보통 timer나 animation을 통할 것 같은데요,

원본 포스트에서 위와 같이 좋은 방법, 나쁜 방법이라고 소개를 해놓은 점은 굉장히 자극적이라는 생각이 듭니다.

그래서 line-through 처리를 한 것이기도 하구요,

사실 원본 포스트에서도 밑 부분에는 각 방법마다 장단점을 작성해놓긴 했습니다.


프로젝트마다 splash 화면이 구성되는 동안, 

간단한 작업을 하거나 animation을 보여주는 경우가 있습니다.

launcher theme 방법의 경우 그것이 불가능합니다. 단순히 이미지를 표시하는 역할인 것이죠.

머무를 시간을 정한다던지,

animation을 표현한다든지,

login 등 간단한 request를 한다든지 그 어떤 행위랑은 연관이 없습니다.


따라서, splash 화면에서 간단한 작업(무거운 작업은 당연히 피해야겠죠)을 하고자 한다면, 

따로 화면을 구성하는 것이 더 적절하지 않나 생각합니다.


예를 들어, 

splash 화면을 뿌리는 동안 서버에 나의 상태를 요청하고, 

그상태에 따라 넘어가는 activity가 다른 경우가 있겠습니다.

물론 가능은 하겠지만, 하나의 activity에 splash가 종속되는 바람에 

launcher activity의 코드가 조금 장황해질 것 같다는 의견입니다.


따라서, 어떤 방법을 택할지는 본인의 판단하에 선택하면 될 것 같습니다 :)



'programming > android' 카테고리의 다른 글

어떤 Context를 써야 하나요?  (0) 2018.03.26
기본적인 메모리 관리  (0) 2018.03.06
Kotlin Coroutines #2  (0) 2018.01.28
Kotlin Coroutines #1  (1) 2018.01.27
Tools로 xml layoyt의 preview 제대로 표시하기  (0) 2018.01.22

+ Recent posts