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

时间:2014-07-22 08:19:07

标签: android xml

我知道这里有一百个问题就像我的一样,但它们似乎都不适合我的具体问题,所以我问了一个新问题。万一这是重复,我很抱歉。

所以,我正在构建一个应用程序,布局给我带来了一些问题 这是我的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'的资源标识符

我已经遍及代码,我已经尝试刷新/重建项目,我尝试删除该特定行等等。似乎没有什么可以解决它。

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

谢谢!

4 个答案:

答案 0 :(得分:2)

删除

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>

答案 1 :(得分:1)

将其替换为

  <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>

答案 2 :(得分:1)

哦,我很抱歉! 我发现了我的错误,它在我的第一个LinearLayout标记的最后一个属性中。

我不应该在底部包含该行 我删除了该行,现在它正在工作。

非常感谢你们!

答案 3 :(得分:0)

如果以上工作都没有确保你添加:  编译'com.android.support:percent:23.1.1'

到你的build.gradle