I can not understand the reason. Made the loading screen, but the components that it placed on it are not displayed. There are no errors in the console

splash_screen.xml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg" android:orientation="horizontal"> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top" android:adjustViewBounds="true" android:contentDescription="@string/app_name" android:padding="15dp" app:srcCompat="@drawable/app_name" /> <ImageView android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:adjustViewBounds="true" android:contentDescription="@string/app_name" android:padding="50dp" app:srcCompat="@drawable/icon_phone" /> </FrameLayout> 

SplashScreenActivity

 public class SplashScreenActivity extends Activity { // Время в милесекундах, в течение которого будет отображаться Splash Screen private final int SPLASH_DISPLAY_LENGTH = 3000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash_screen); //getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); new Handler().postDelayed(new Runnable() { @Override public void run() { // По истечении времени, запускаем главный активити, а Splash Screen закрываем Intent mainIntent = new Intent(SplashScreenActivity.this, MainActivity.class); SplashScreenActivity.this.startActivity(mainIntent); SplashScreenActivity.this.finish(); } }, SPLASH_DISPLAY_LENGTH); } } 

Stektreys

 04-24 07:02:20.225 5986-5986/ru.test.kidsphone E/AndroidRuntime: FATAL EXCEPTION: main Process: ru.test.kidsphone, PID: 5986 java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.test.kidsphone/ru.test.kidsphone.SplashScreenActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:359) at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:328) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at ru.test.kidsphone.SplashScreenActivity.onCreate(SplashScreenActivity.java:15) at android.app.Activity.performCreate(Activity.java:6662) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
  • Comments are not intended for extended discussion; conversation moved to chat . - PashaPash

1 answer 1

Using the app:srcCompat , you need to inherit AppCompatActivity , instead of Activity , since Activity implementation, does not know about the methods of the support library.

  • I realized thanks. - Cristina