Я пытался внедрить заставку в свое приложение, но он просто показывает мне черный экран в течение того времени, которое я ему сказал.
Манифест:
<activity android:name = ".SplashScreen"
android:theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name = "android.intent.action.MAIN"/>
<category android:name = "android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Ява:
public class SplashScreen extends FragmentActivity {
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
new Handler().postDelayed(new Runnable(){
@Override
public void run(){
Intent i = new Intent(SplashScreen.this,RSR_Revalidatieservice.class);
startActivity(i);
finish();
}
},SPLASH_TIME_OUT);
}
}
XML:
<android.support.constraint.ConstraintLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:app = "http://schemas.android.com/apk/res-auto"
xmlns:tools = "http://schemas.android.com/tools"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
tools:context = ".SplashScreen">
<ImageView
android:id = "@+id/imageView2"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_marginBottom = "32dp"
app:layout_constraintBottom_toBottomOf = "parent"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent"
app:srcCompat = "@drawable/splash_logo_rsr" />
<ImageView
android:id = "@+id/imageView3"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_marginTop = "16dp"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintHorizontal_bias = "0.503"
app:layout_constraintStart_toStartOf = "parent"
app:layout_constraintTop_toTopOf = "parent"
app:srcCompat = "@drawable/splash_logo" />
</android.support.constraint.ConstraintLayout>
Я всего лишь пытаюсь показать заставку примерно на 3 секунды, поэтому не нужно «загружать» приложение или около того в фоновом режиме, я просто хотел крутой эффект запуска.
Заменять:
android:theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen" из вашего манифеста
с участием:
android:theme = "@style/AppTheme.NoActionBar"
Вместо apptheme используйте Theme
Теперь он показывает мне белый экран без двух изображений... Тем не менее, это прогресс
@PhilémonRoubaud вместо src compat set src
Apptheme не может быть разрешен как символ... Пробовал использовать @android:style/Theme.Holo.NoActionBar, но это не сработало!