Xamarin Android Forms设计器无法识别GridLayout布局参数

时间:2017-12-20 03:37:33

标签: android xamarin xamarin.android

我正在使用表格布局设计表单,但编译器抱怨许多属性未定义或不允许。这是布局的片段:

<GridLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/gridLayout1"
    android:columnCount="2"
    android:rowCount="2">
    <LinearLayout
        android:orientation="vertical"
        android:minWidth="25px"
        android:minHeight="25px"
        android:id="@+id/player1Layout"
        android:layout_column="0"
        android:layout_row="0"
        android:background="@android:color/holo_green_dark"
        android:layout_gravity="fill"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:layout_margin="1" />

编译时,我会收到与layout_*属性相关的警告和错误。目前,我已经设置了所有三个API级别(编译,目标和最小)26,我非常确定它具有所有这些属性,但是我得到以下错误:

error APT0000: 1: error: Error: Integer types not allowed (at 'layout_margin' with value '1').
error APT0000: 1: error: Error: Integer types not allowed (at 'layout_margin' with value '1').
error APT0000: 1: error: Error: Integer types not allowed (at 'layout_margin' with value '1').
error APT0000: 1: error: Error: Integer types not allowed (at 'layout_margin' with value '1').

The 'http://schemas.android.com/apk/res/android:layout_column' attribute is not declared.
The 'http://schemas.android.com/apk/res/android:layout_row' attribute is not declared.
The 'http://schemas.android.com/apk/res/android:layout_columnWeight' attribute is not declared.
The 'http://schemas.android.com/apk/res/android:layout_rowWeight' attribute is not declared.

1 个答案:

答案 0 :(得分:1)

  

错误APT0000:1:错误:错误:不允许整数类型(在&#39; layout_margin&#39;值为&#39; 1&#39;)。

使用dp单位,即:

android:layout_margin="1dp"