Carter Roeser Carter Roeser - 17 days ago 12
Android Question

@color/gray “Validates resource references inside Android XML files”

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>

Answer

add value to color in your color.xml like below

 <color name="grey">#6E6E6E</color>