Android XML 错误:在包"android"中找不到属性"xmlns"的资源标识符



我知道这里有一百多个和我一样的问题,但似乎没有一个适合我的具体问题,所以我要问一个新的问题。为了防止再次发生,我很抱歉。

所以,我正在构建一个应用程序,布局给我带来了一些问题。
这是我的XML代码:(它还没有完成)

  <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/toosl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
android:xmlns="http://schemas.android.com/apk/res/android" >
<TextView
    android:id="@+id/showNunmber"
    android:layout_width="wrap_content"
    android:layout_marginTop="15dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="number"
    android:textSize="30sp"/>
<TextView
    android:id="@+id/showAnswer"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="answer"
    android:layout_marginTop="35dp"
    android:layout_gravity="center"
    android:textSize="25sp"/>
 </LinearLayout>

我得到的错误在代码的第一行当它说"错误:在包'android'中没有找到属性'xmlns'的资源标识符

我一遍又一遍地看代码,我试过刷新/重建项目,我试过删除那一行,等等。似乎没有什么能解决这个问题。

那么,如果有人有什么想法?

谢谢!

删除

android:xmlns="http://schemas.android.com/apk/res/android"

从你的布局,即使用

布局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/toosl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
    android:id="@+id/showNunmber"
    android:layout_width="wrap_content"
    android:layout_marginTop="15dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="number"
    android:textSize="30sp"/>
<TextView
    android:id="@+id/showAnswer"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="answer"
    android:layout_marginTop="35dp"
    android:layout_gravity="center"
    android:textSize="25sp"/>
 </LinearLayout>

将其替换为

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:orientation="vertical"
    >
    <TextView
        android:id="@+id/showNunmber"
        android:layout_width="wrap_content"
        android:layout_marginTop="15dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="number"
        android:textSize="30sp"/>
    <TextView
        android:id="@+id/showAnswer"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="answer"
        android:layout_marginTop="35dp"
        android:layout_gravity="center"
        android:textSize="25sp"/>
     </LinearLayout>

我发现了我的错误,它在我的第一个LinearLayout标签的最后一个属性。

我不应该把那行放在底部。
我删除了那行,现在它工作了。

谢谢!

如果以上都不起作用,请确保添加以下内容:编译'com.android.support:percent:23.1.1'

到您的构建。gradle

最新更新