我必须创建一个启动屏幕并根据指南进行尝试 this和this。
当我创建layout/launch_screen.xml
并将此代码放入其中时,它会正确显示在Android Studio的设计内部,但会产生错误
org.xmlpull.v1.XmlPullParserException:未终止的实体引用(位置:TEXT PNG)
完整代码可@layout/launch_screen
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="#652D6C"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/launch_screen"
android:contentDescription="@string/image_description"/>
</LinearLayout>
完整的错误日志在这里:
org.xmlpull.v1.XmlPullParserException: unterminated entity ref
(position:TEXT PNG IHDR...@4:50 in
java.io.InputStreamReader@5fc473ec) at org.kxml2.io.KXmlParser.exception
at org.kxml2.io.KXmlParser.error
at org.kxml2.io.KXmlParser.pushEntity
at org.kxml2.io.KXmlParser.pushText
at org.kxml2.io.KXmlParser.nextImpl
at org.kxml2.io.KXmlParser.next at
com.android.layoutlib.bridge.android.BridgeXmlBlockParser.next(BridgeXmlBlockParser.java:302)
at
com.android.layoutlib.bridge.impl.ResourceHelper.getInternalComplexColor(ResourceHelper.java:170)
at com.android.layoutlib.bridge.impl.ResourceHelper.getColorStateList(ResourceHelper.java:222)
at android.content.res.Resources_Delegate.getColorStateList(Resources_Delegate.java:262)
at android.content.res.Resources.getColorStateList(Resources.java:1017)
at android.content.Context.getColorStateList(Context.java:621)
at android.support.v7.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:65)
at android.support.v7.widget.TintTypedArray.getColorStateList(TintTypedArray.java:171)
at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:71)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:78)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at
android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at
android.view.LayoutInflater.inflate(LayoutInflater.java:394) Copy
stack to clipboard
并不是说我有用于png的mipmap文件夹,并且还创建了@drawable/launch_screen.xml
,但现在似乎没有使用它。
我的启动画面现在仅显示背景颜色,而不呈现png
答案 0 :(得分:3)
尝试像这样使用android.support.v7.widget.AppCompatImageView
代替ImageView
:
<android.support.v7.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/launch_screen"
android:contentDescription="@string/image_description"/>