Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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 错误:添加ScrollView后分析XML:未绑定前缀时出错_Android_Xml_Parsing_Scrollview_Prefix - Fatal编程技术网

Android 错误:添加ScrollView后分析XML:未绑定前缀时出错

Android 错误:添加ScrollView后分析XML:未绑定前缀时出错,android,xml,parsing,scrollview,prefix,Android,Xml,Parsing,Scrollview,Prefix,将scrollview添加到xml文件后,我在第4行遇到错误。 我尝试过移动xmlns:android=”http://schemas.android.com/apk/res/android“但仍会收到相同的错误 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ScrollView01" android:layout_width="fill_parent" and

将scrollview添加到xml文件后,我在第4行遇到错误。 我尝试过移动
xmlns:android=”http://schemas.android.com/apk/res/android“
但仍会收到相同的错误

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
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="com.easy.convert.MainActivity" >

<ImageButton
    android:id="@+id/btnbitsbytes"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="25dp"
    android:background="#00000000"
    android:gravity="center"
    android:src="@drawable/btnbitsbytes" />

<ImageButton
    android:id="@+id/btnmassweight"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/btnbitsbytes"
    android:layout_below="@+id/btnbitsbytes"
    android:layout_marginTop="14dp"
    android:background="#00000000"
    android:src="@drawable/btnmassweight" />

<ImageButton
    android:id="@+id/ButtonConvert"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/btnmassweight"
    android:layout_below="@+id/btnmassweight"
    android:layout_marginTop="14dp"
    android:background="#00000000"
    android:src="@drawable/btnlength" />

<ImageButton
    android:id="@+id/imageButton3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/ButtonConvert"
    android:layout_below="@+id/ButtonConvert"
    android:layout_marginTop="14dp"
    android:background="#00000000"
    android:src="@drawable/btntemperature" />

<ImageButton
    android:id="@+id/imageButton4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/imageButton3"
    android:layout_below="@+id/imageButton3"
    android:layout_marginTop="15dp"
    android:background="#00000000"
    android:src="@drawable/btndistance" />

<ImageButton
    android:id="@+id/imageButton5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/imageButton4"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="22dp"
    android:background="#00000000"
    android:src="@drawable/btnaboutus" />

</RelativeLayout>
</ScrollView>

删除
xmlns:android=”http://schemas.android.com/apk/res/android“
用于
相对性。这仅适用于根元素ie
ScrollView

<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>
或添加
xmlns:tools=”http://schemas.android.com/tools“

是android的xml名称空间

 xmlns:tools="http://schemas.android.com/tools"
http://schemas.android.com/tools
是名称空间uri,前缀是
tools
。您可以找到“工具”属性的列表@


您拥有
工具:context=“com.easy.convert.MainActivity”
属性。您还需要声明
tools
名称空间前缀,如
android
声明:

xmlns:tools="http://schemas.android.com/tools"

从您的
RelativeLayout
中删除
xmlns
行,然后重试。重复
xmlns:android
是一个错误,但它会产生另一个错误消息。如果删除它没有帮助,考虑更多的XML.这并不能解决这个问题,但这是另一个观察:<代码>“FILIHORE OND”从API级别8(包括在内)被弃用。使用
“匹配父项”
,instead@Tanmay张贴整个xml@Tanmay删除此
tools:context=“com.easy.convert.MainActivity”
而不是删除此行,我添加了xmlns:tools=“”行。你能告诉我工具:context的用途吗?@Tanmay你可以这么做,非常感谢Raghundandan!:)非常感谢@laalto!
xmlns:android="http://schemas.android.com/apk/res/android
 xmlns:tools="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/tools"