시작할 때 2 초 동안 흰색 화면을 표시하는 Android 앱이 있습니다. 내 다른 앱은이 작업을 수행하지 않지만이 작업은 수행합니다. 나는 또한 이것을 고칠 것이라는 희망으로 스플래시 스크린을 구현했습니다. 스플래시 화면 수면 시간을 늘려야합니까? 감사.
답변
AndroidManifest.xml 파일의 시작 활동에 투명 테마를 언급하기 만하면됩니다.
처럼:
<activity
android:name="first Activity Name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Activity
대신 클래스를 사용하여 화면을 확장하십시오 AppCompatActivity
.
처럼 :
public class SplashScreenActivity extends Activity{
----YOUR CODE GOES HERE----
}
답변
이것을 사용자 정의 스타일에 넣으면 모든 문제가 해결됩니다. 해키 반투명 수정을 사용하면 작업 표시 줄과 탐색 모음이 반투명 해지고 스플래시 화면 또는 기본 화면이 스파게티처럼 보입니다.
<item name="android:windowDisablePreview">true</item>
답변
튜브처럼 .. 처음에는 흰색 화면 대신 아이콘 화면을 표시합니다. 그리고 2 초 후에 홈 화면이 표시됩니다.
먼저 res / drawable에서 XML 드로어 블을 만듭니다.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/gray"/>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher"/>
</item>
</layer-list>
다음으로 이것을 테마에서 스플래시 활동의 배경으로 설정합니다. styles.xml 파일로 이동하여 스플래시 활동에 대한 새 테마를 추가하십시오.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
</resources>
새 SplashTheme에서 창 배경 속성을 XML 드로어 블로 설정합니다. AndroidManifest.xml에서 스플래시 활동의 테마로이를 구성하십시오.
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
이 링크는 원하는 것을 제공합니다. 단계별 절차.
https://www.bignerdranch.com/blog/splash-screens-the-right-way/
최신 정보:
는 다음 layer-list
과 같이 더 간단 할 수 있습니다 ( <bitmap>
태그 와 달리 중앙 로고에 벡터 드로어 블도 허용 ).
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Background color -->
<item android:drawable="@color/gray"/>
<!-- Logo at the center of the screen -->
<item
android:drawable="@mipmap/ic_launcher"
android:gravity="center"/>
</layer-list>
답변
다음과 같이 style.xml에서 스타일을 만드십시오.
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsTranslucent">true</item>
</style>
AndroidManifest의 활동과 함께 다음과 같이 사용하십시오.
<activity android:name=".ActivitySplash" android:theme="@style/Theme.Transparent">
답변
Cyril Mottier의이 멋진 게시물을 읽어야합니다. Android 앱 출시가 멋지게 시작되었습니다.
당신은 당신을 사용자 정의 할 필요가 Theme
귀하의 사용자 정의 할 수 style.xml 및 피하기에 onCreate
ActionBar.setIcon로 / setTitle이라는 / 등.
Google의 성능 팁 에 대한 문서도 참조하십시오 .
사용 Trace View
하고 Hierarchy Viewer
당신의보기를 표시 할 수있는 시간을 볼 수 : 안드로이드의 성능 최적화 / 성능 튜닝에 안드로이드를
AsyncTask
일부보기를 표시하는 데 사용 합니다.
답변
이것은 예제 앱의 내 AppTheme입니다.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
당신이 볼 수 있듯이, 나는 기본 색상을하고 난을 추가 android:windowIsTranslucent
하고로 설정합니다 true
.
내가 Android 개발자로 알고있는 한, 이것은 애플리케이션 시작시 흰색 화면을 숨기려면 설정해야하는 유일한 것입니다.
답변
두 속성 모두 둘 중 하나를 사용합니다.
<style name="AppBaseThemeDark" parent="@style/Theme.AppCompat">
<!--your other properties -->
<!--<item name="android:windowDisablePreview">true</item>-->
<item name="android:windowBackground">@null</item>
<!--your other properties -->
</style>