2013-06-02 23 views
1
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scroll" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <LinearLayout 
    *** 

的xmlns:工具= 「http://schemas.android.com/tools」 *此行顯示了錯誤爲標籤LinearLayout找到意外的命名空間前綴「xmlns」,我嘗試了堆棧上的解決方案,但沒有得到解決。請幫忙。意外的命名空間前綴 「的xmlns」 找到的標籤的LinearLayout(的xmlns:工具ERROR)

android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" 
    android:id="@+id/RL"> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/hello_world" 
     android:id="@+id/label1" /> 


</LinearLayout> 
</ScrollView> 

回答

2

它抱怨屬性tools:context=".MainActivity"這是<LinearLayout>標籤的一部分。它不知道tools:前綴的含義。

您需要將xmlns:tools="http://schemas.android.com/tools"作爲屬性添加到<ScrollView>標記。或者,也可以刪除<LinearLayout>標記的tools:context屬性。

tools:context(以及其他tools:...屬性)用作Android的lint檢查XML文件的一部分。有關更多信息,請參閱here

+0

我擺脫了工具:上下文,我是一個初學者程序員,所以原諒我,但不會導致我的程序中有任何衝突? – mohammedri

+0

@RidwanWan - 對於您發佈的文件,我認爲不管添加名稱空間聲明還是刪除'tools:context'屬性都沒有什麼區別。這是爲了這個特定的文件。一般來說,刪除所有'tools:*'屬性意味着Android lint工具不會有太多的信息可用;因此它可能會產生虛假警告或無法產生警告來幫助追蹤問題。 –

+0

這聽起來很公平,但它解決了問題! 謝謝! – mohammedri

相關問題