Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.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
C# 分析XAML时出错:“引用”;“不允许使用整数类型”;许多属性(如宽度)的错误_C#_Android_Xml_Compiler Errors_Xamarin.android - Fatal编程技术网

C# 分析XAML时出错:“引用”;“不允许使用整数类型”;许多属性(如宽度)的错误

C# 分析XAML时出错:“引用”;“不允许使用整数类型”;许多属性(如宽度)的错误,c#,android,xml,compiler-errors,xamarin.android,C#,Android,Xml,Compiler Errors,Xamarin.android,所以,我是一个新的Xamarin开发人员,我被一些非常基本的东西困住了。编译器在android:inputType=“textEmailAddress”行中给出错误。错误是解析XML时出错:未绑定前缀 我已尝试将所有这些元素添加到根元素中(在我的示例中为线性布局),但不起作用: xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" xmlns:android="http://schemas.android.com/apk/re

所以,我是一个新的Xamarin开发人员,我被一些非常基本的东西困住了。编译器在android:inputType=“textEmailAddress”行中给出错误。错误是解析XML时出错:未绑定前缀

我已尝试将所有这些元素添加到根元素中(在我的示例中为线性布局),但不起作用:

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
以下是完整的代码:

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

    <RelativeLayout
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/relativeLayout1">
        <ImageView
            android:src="@drawable/loginbgandbtnldpi"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/LoginBGImgView" />
        <EditText
            android:inputType="textEmailAddress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/LoginEmailEditText"
            android:width="300"
            android:layout_marginTop="295"
            android:layout_marginLeft="30"
            android:text="Email"
            app:paddingStart="20"
            android:paddingLeft="35"/>
        <EditText
            android:inputType="textPassword"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/LoginPassEditText"
            android:text="Password"
            android:width="300"
            android:paddingLeft="35"
            android:layout_marginLeft="30"
            android:layout_marginTop="348" />
        <Button
            android:id="@+id/LoginButton"
            android:clickable="true"
            android:layout_marginTop="432"
            android:layout_marginLeft="100"
            android:width="160"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:visibility="invisible" />
    </RelativeLayout>

</LinearLayout>
新错误列表:

严重性代码描述项目文件行抑制状态
不允许使用错误整数类型(在“layout\u marginLeft”处,值为“100”)。
不允许使用错误整数类型(在“layout\u marginLeft”处,值为“30”)。
不允许使用错误整数类型(在“layout\u marginLeft”处,值为“30”)。
不允许使用错误整数类型(在值为“30”的“layout_marginRight”处)。
不允许使用错误整数类型(在值为“30”的“layout_marginRight”处)。
不允许使用错误整数类型(在“layout_marginTop”处,值为“295”)。
不允许使用错误整数类型(在“layout_marginTop”处,值为“348”)。
不允许使用错误整数类型(在'layout_marginTop'处,值为'432')。
不允许使用错误整数类型(在“paddingLeft”处,值为“35”)。
不允许使用错误整数类型(在“paddingLeft”处,值为“35”)。
不允许错误整数类型(在“宽度”处,值为“160”)。
不允许错误整数类型(在“宽度”处,值为“300”)。
不允许错误整数类型(在“宽度”处,值为“300”)。
编辑2: 通过使用整数值指定“dp”解决了此问题。

使用SP作为文本大小(与比例无关的像素) 和DP表示所有其他内容(密度无关像素)

使用SP表示文本大小(比例无关像素)
还有其他的DP(与密度无关的像素)

我将发布我在评论中给出的答案:


这是因为你需要给出一个单位,只有300个单位不行:android:width=“300dp”

我将发布我在评论中给出的答案:

这是因为你需要给出一个单位,只有300个单位不行:android:width=“300dp”

这是来自android的文档

要在不同密度的屏幕上保持用户界面的可见大小,必须使用密度无关像素(
dp
)作为测量单位来设计用户界面。一个dp是一个虚拟像素单位,大致相当于中等密度屏幕上的一个像素(160dpi;“基线”密度)。Android会将该值转换为适合彼此密度的真实像素数

例如,指定两个视图之间的间距时,请使用
dp

<Button android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/clickme"
    android:layout_marginTop="20dp" />
因此这里的解决方案应该为axml中的布局添加
dp

这里是来自android文档的

要在不同密度的屏幕上保持用户界面的可见大小,必须使用密度无关像素(
dp
)作为测量单位来设计用户界面。一个dp是一个虚拟像素单位,大致相当于中等密度屏幕上的一个像素(160dpi;“基线”密度)。Android会将该值转换为适合彼此密度的真实像素数

例如,指定两个视图之间的间距时,请使用
dp

<Button android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/clickme"
    android:layout_marginTop="20dp" />

因此这里解决方案应该为axml中的布局添加
dp

xml无效。您需要在xml的第2行定义名称空间“app”,其属性类似于“android”。或者您可能希望
android:paddingStart=“20”
而不是
app:paddingStart=“20”
。您可以使用查找像这样的XML错误。@dbc感谢您的评论,它解决了问题,但在我为属性指定了和整数值的地方出现了其他错误
android:width=“300”
现在在('wdith'和值为'300')处不允许出现错误@HammadNasir its因为你需要给出一个单位,所以
300
不行:
android:width=“300dp”
(不确定dp是否适用于xamarin)@dbc它可以解决问题,但它不是标题中问题的答案,所以我猜xml无效。你需要用“android”这样的属性定义名称空间“app”“是在xml的第2行定义的。或者您可能希望使用
android:paddingStart=“20”
而不是
app:paddingStart=“20”
。您可以使用查找像这样的XML错误。@dbc感谢您的评论,它解决了问题,但在我为属性指定了和整数值的地方出现了其他错误
android:width=“300”
现在在('wdith'和值为'300')处不允许出现错误@HammadNasir因为你需要给一个单位,所以它只是
300
不行:
android:width=“300dp”
(不确定dp是否在xamarin上起作用)@dbc它可以解决问题,但它不是标题中问题的答案,所以我猜不会
<TextView android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="20sp" />