Reputation: 360
I followed the directions on https://www.bignerdranch.com/blog/splash-screens-the-right-way/ to make a splash screen for my app, but in my background_splash.xml file, the code:
<item android:drawable="@color/gray"/>
returns the message “Validates resource references inside Android XML files”.
How do I fix this? Thanks!
Update with code:
background_splash.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/white"/>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/splash"/>
</item>
</layer-list>
SplashActivity.java:
package PACKAENAME;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="PACKAGENAME">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
</activity>
</application>
</manifest>
Upvotes: 1
Views: 2359
Reputation: 645
I'm not an android developer so when the correct answer says to
add value to color in your color.xml like below
I don't exactly know what that means.
What it means is. Go to this path inside your android app
app/src/main/res/values/
and create or use the file called "colors.xml". Then add the grey value to it (or any other color value you need)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="grey">#6E6E6E</color>
</resources>
When using the custom color make sure to use
<item android:drawable="@color:grey" />
instead of android colors
<item android:drawable="@android:color/custom_color" />
Upvotes: 0
Reputation: 1354
add value to color in your color.xml like below
<color name="grey">#6E6E6E</color>
Upvotes: 2