布局中的布局 <layout> 在基本布局文件夹中没有声明 \[错误\]

新手上路,请多包涵

我在应用布局的 Android Studio 中收到以下错误:

layout 中的布局在基本布局文件夹中没有声明;当在与此限定符不匹配的配置中查询资源时,这可能会导致崩溃

我收到此错误的布局之一是:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@null" >

      <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top|center_horizontal"
            android:adjustViewBounds="true"
            android:contentDescription="@string/hello_world"
            android:src="@drawable/loading_top" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:adjustViewBounds="true"
            android:contentDescription="@string/hello_world"
            android:src="@drawable/loading_bottom" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:contentDescription="@string/hello_world"
            android:background="@color/white"
            android:layout_marginBottom="5dp"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:src="@drawable/loading_logo" />

        <ImageView
            android:id="@+id/loading"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center|center_vertical"
            android:layout_marginBottom="0dp"
            android:layout_marginTop="0dp"
            android:contentDescription="@string/hello_world"
            android:scaleType="fitXY"
            android:src="@null" />
    </FrameLayout>
</LinearLayout>

我在第一个 LinearLayout 的第一行得到错误。

有谁知道如何解决这个错误?

谢谢

更新:用什么解决了我的问题回答了我的问题

原文由 L Kemp 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.1k
2 个回答

我已经使用 Windows 资源管理器复制了文件夹中的 xml 文件。它似乎导致了编码问题。删除文件并在 Android Studio 中处理后,问题得到解决。

原文由 L Kemp 发布,翻译遵循 CC BY-SA 4.0 许可协议

对我来说,这是因为我不小心用空格键而不是下划线命名了文件,即 fragment_item summary.xml 而不是 fragment_item_summary.xml

原文由 Saligia 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题