Xamarin.Android C# layout_weight 错误:必须指定一个单位,例如“px”(智能感知?)

Mic*_*ury 14 c# visual-studio xamarin.android

我的布局的一个片段:

        <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:text="@string/moreInfo"
            android:layout_width="wrap_content"
            android:layout_weight= "1"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:id="@+id/moreInfo" />
Run Code Online (Sandbox Code Playgroud)

我收到一个 IntelliSense 错误:必须为文件中的每个 android:layout_weight 实例指定一个单位,例如“px”。我已经尝试将 WeightSum 添加到 LinearLayout 并从 int 更改为 float (尽管仍然在引号中),但错误仍然存​​在。

奇怪的是(至少对我而言)我仍然可以在模拟器上构建/运行我的代码。我的猜测是它是 IntelliSense 中的东西,我不喜欢明显的错误,即使它们是错误的......

使用 VS2019 社区。

ssh*_*haw 8

这是 Visual Studio 及其新分析器中的一个错误。除了它出现在错误列表中的烦恼之外,它不应该影响应用程序构建或运行它。

真诚的编写错误的跛脚开发人员:)

PS,我真的很抱歉给您带来麻烦,我现在正在努力修复它。

PPS,我会确保添加单元测试。

更新:一个修复程序应该会出现在接下来的几个 16.9 预览版中


小智 2

刚刚在我的 VS 2019 社区中尝试了您的代码,对我来说没有 IntelliSense 错误。

可能是 IntelliSense 缓存吗?

  1. 关闭VS
  2. 删除解决方案根目录中的 .vs 文件夹
  3. 开始VS