【问题标题】:Xamarin Android Forms designer does not recognize GridLayout layout parametersXamarin Android 窗体设计器无法识别 GridLayout 布局参数
【发布时间】:2017-12-20 12:35:53
【问题描述】:

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

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

【问题讨论】:

  • 您的“layout_margin”错误是不允许使用整数类型,是的,它允许与密度无关的点....类似于 android:layout_marginRight="1dp"

标签: android xamarin xamarin.android


【解决方案1】:

错误 APT0000:1:错误:错误:不允许使用整数类型(在“layout_margin”处,值为“1”)。

使用dp 单位,即:

android:layout_margin="1dp"

【讨论】:

  • 嗯。奇怪的;我通过设计器 UI 设置它,它正确地更新了所见即所得的渲染。
猜你喜欢
  • 1970-01-01
  • 2018-06-08
  • 1970-01-01
  • 2014-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多