Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将drawable设置为背景以查看返回的drawable未找到_Android_Xml_Kotlin - Fatal编程技术网

Android 将drawable设置为背景以查看返回的drawable未找到

Android 将drawable设置为背景以查看返回的drawable未找到,android,xml,kotlin,Android,Xml,Kotlin,以前我总是在视图中添加可绘制的背景。但最近,当我在任何视图(如LinearLayout、view、TextView)中添加一个可绘制的背景时,我得到了这个错误 error: resource drawable/rectangle_white (aka merchant.com.our.nextlounge:drawable/rectangle_white) not found. Message{kind=ERROR, text=error: resource drawable/rectangl

以前我总是在视图中添加可绘制的背景。但最近,当我在任何视图(如LinearLayout、view、TextView)中添加一个可绘制的背景时,我得到了这个错误

 error: resource drawable/rectangle_white (aka merchant.com.our.nextlounge:drawable/rectangle_white) not found.
Message{kind=ERROR, text=error: resource drawable/rectangle_white (aka merchant.com.our.nextlounge:drawable/rectangle_white) not found., sources=[C:\Users\USER\Documents\Exolve Project\NextLounge\app\src\main\res\layout\activity_dash_auth.xml:45], original message=, tool name=Optional.of(AAPT)}
我已经刷新,清理,建立,但它不工作。唯一可行的方法是添加多个可绘制API文件夹,如
drawable-v21、drawable-v22、drawable-v23

让它工作。 请说明如何解决此问题

<?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="match_parent"
tools:context=".activity.DashAuthActivity">
<include layout="@layout/background_auth"/>

  <include layout="@layout/logo"
   android:id="@+id/logo"
   android:layout_height="wrap_content"
   android:layout_width="wrap_content"
   app:layout_constraintLeft_toLeftOf="parent"
   app:layout_constraintRight_toRightOf="parent"
   app:layout_constraintTop_toTopOf="parent"/>
<TextView
    android:id="@+id/text"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:text="@string/intro_text"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@id/logo"
    app:layout_constraintBottom_toBottomOf="@id/linearLine"
    android:layout_margin="20sp"
    app:layout_constraintVertical_bias="0.0"
    android:padding="8dp"
    android:textAlignment="center"
    android:textColor="@color/white"/>
<LinearLayout
    android:id="@+id/linearLine"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="4"
    android:padding="4dp"
    android:layout_margin="24dp"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintVertical_bias="0.96"
    app:layout_constraintBottom_toTopOf="@+id/linearButton"
    android:layout_marginBottom="20sp">
    <View
        android:layout_width="0dp"
        android:layout_height="6dp"
        android:background="@drawable/rectangle_white"
        android:layout_weight="2.5"/>
    <View
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:layout_weight="0.3"/>
    <View
    android:layout_width="0dp"
    android:layout_height="6dp"
    android:background="@drawable/rectangle_white_line"
    android:layout_weight="1.2"/>
</LinearLayout>
 <LinearLayout
android:id="@+id/linearButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4"
android:padding="4dp"
android:layout_margin="20dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent">

   <Button
    android:id="@+id/buttonSignIn"
    android:layout_width="0dp"
    android:layout_height="48dp"
    android:layout_weight="2"
    android:layout_marginRight="4dp"
    android:layout_marginEnd="4dp"
    android:text="@string/sign_in"
    android:textColor="@color/black"
    android:textAllCaps="false"
    android:textSize="18sp"
    android:background="@color/white"/>
    <Button
    android:id="@+id/buttonSignUp"
    android:layout_width="0dp"
    android:layout_height="48dp"
    android:layout_weight="2"
    android:layout_marginLeft="4dp"
    android:layout_marginStart="4dp"
    android:text="@string/sign_up"
    android:textAllCaps="false"
    android:textSize="18sp"
    android:textColor="@color/white"
    android:background="@color/orange"/>


在运行时,将选择最适合设备android版本的可绘制文件夹,
除非只有一个可绘制文件夹,在这种情况下,只有一个可绘制文件夹
由于
drawable-v21
drawable-v22
drawable-v23
等中的另一个版本的drawable可以工作,
但是主
drawable
中的drawable不工作,这意味着后一个drawable是问题所在

我建议您检查xml结构中的错误,或者如果可能的话重新创建它

嗨,谢谢你们的回复。我所要做的就是删除整个可绘制文件夹和所有内容,然后创建一个新的可绘制文件夹并重新创建所有文件。
一旦我这么做了,我就运行了它,它对所有android设备都很好。因此,我不必为不同的API版本创建特定的文件夹

将您的代码发布给其他人,以了解您到底在做什么您确定drawable文件夹中有
矩形\u白色
文件吗?因为在另一个示例中,您使用的是
rectangle\u white\u line
我只有一个可绘制文件夹,它在构建过程中显示此错误。但是,如果我创建了单独的API版本文件夹,它会成功构建如果我创建了单独的API版本文件夹,它会在您创建这些文件夹后成功构建,您会重新创建此可绘制文件夹并将其放入这些文件夹中吗?是的,我会将它们复制到新的可绘制文件夹中,并且工作正常。但它的缺点是,我必须为每个API版本创建一个可绘制的文件夹,以便在不同的android手机上运行,那么主要的可绘制就是问题所在。你能重新创建它吗?我已经删除了它,创建了一个新的可绘制目录,并复制了所有的xml文件,但仍然有相同的问题
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="rectangle">
  <stroke android:color="#fff"
     android:width="2dp"/>

</shape>