I am trying to add a Splash Screen to an existing mobile app for Android using Android Studio. From everything I have researched, I need to be using AppCompat to do this, but each time I try to add it to my styles.xml file, Android Studio tells me "cannot resolve symbol "AppCompat"". Is there somewhere else I should be adding this prior to the styles page in order to have code accept it? My code is below.
Styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppCompat">
<item name="android:colorPrimary"></item>
</style>
<style name="SplashTheme" parent="Theme.AppTheme">
<item name="android:windowBackground">@drawable/background</item>
</style>
</resources>
I tried adding it to my AndroidManifest.xml file to no effect, I receive the error "Unknown resource type" in that file.
When I attempted to change my Main file to: "public class Snake extends AppCompatActivity" I receive the "Cannot resolve symbol" error again.
I feel like the guides I have read are leaving out some crucial, yet shockingly obvious, step that most people familiar with Android would know quite well. Regretfully, I am still quite new to Android and trying to learn.
You should have compile "com.android.support:appcompat-v7:25.3.1"
in your Gradle dependencies.
You can create a theme with ActionBar and Without ActionBar. If you use a toolbar in your activity probably you should use without action bar theme. Select your theme accordingly.
Create style file like this.
With ActionBar
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:colorPrimary"></item>
</style>
<style name="SplashTheme" parent="Theme.AppTheme">
<item name="android:windowBackground">@drawable/background</item>
</style>
Without ActionBar
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary"></item>
</style>
<style name="SplashTheme" parent="Theme.AppTheme">
<item name="android:windowBackground">@drawable/background</item>
</style>
Now refer theme in the manifest. Hope it will work:)