如何解决错误:链接文件资源失败



错误显示:

C:\Users\user\AndroidStudioProjects\hamm\app\src\main\res\drawable\black_gradient.xml:4:错误:"00000000"与属性endColor(attr(不兼容颜色C: \Users\user\AndroidStudioProjects\hamm\app\src\main\res\layout\home_item.xml:8:错误:"#e6e6e6"与属性srcCompat(attr(不兼容引用[weak]。错误:链接文件资源失败。

这是black_gradient.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="90" android:startColor="#121212"
android:endColor="00000000" />
</shape>

这是我的home_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="250dp">
<ImageView
android:id="@+id/card_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#e6e6e6" />
<Button
android:background="@drawable/btn_news_style"
android:id="@+id/btn_news"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:text="News And Highlight"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="102dp"
app:layout_constraintBottom_toBottomOf="parent"
app:srcCompat="@drawable/black_gradient"
tools:layout_editor_absoluteX="175dp"
tools:ignore="MissingConstraints" />
<ImageView
android:id="@+id/news_img"
android:layout_width="48dp"
android:layout_height="68dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@mipmap/ic_launcher_round" />
<TextView
android:id="@+id/card_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginBottom="56dp"
android:text="Title"
android:textColor="#fff"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/news_img" />
</android.support.constraint.Constrain

它读作:

错误:"00000000"与属性endColor(attr(颜色不兼容。

您需要使用十六进制表示法:

android:endColor="#000000"

最新更新