c# - Xamarin.Android C# layout_weight 错误 : Must specify a unit,,例如 "px"(智能感知?)

标签 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" />
我收到一个 IntelliSense 错误:必须为文件中的每个 android:layout_weight 实例指定一个单位,例如“px”。我已经尝试将 WeightSum 添加到 LinearLayout 并从 int 更改为 float (尽管仍然在引号中),但错误仍然存​​在。
奇怪的是(至少对我而言)我仍然可以在模拟器上构建/运行我的代码。我的猜测是它是 IntelliSense 中的东西,我不喜欢明显的错误,即使它们是错误的......
使用 VS2019 社区。

最佳答案

这是 Visual Studio 及其新分析器中的一个错误。除了它出现在错误列表中的烦恼之外,它不应该影响应用程序构建或运行它。
真诚的编写错误的跛脚开发人员:)
PS,我真的很抱歉给您带来麻烦,我现在正在努力修复它。
PPS,我会确保添加单元测试。
更新:一个修复程序应该会出现在接下来的几个 16.9 预览版中

关于c# - Xamarin.Android C# layout_weight 错误 : Must specify a unit,,例如 "px"(智能感知?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63419353/

相关文章:

c# - 绑定(bind)到 POCO 列表时,指定的类型转换无效

C# 处理文本文件

c# - 无法在 Xamarin Android 中从 HTML 创建 PDF

c# - MVVM - 我应该公开 ReadOnlyObservableCollection、ReadOnlyCollection、ICollection 等吗?

c# - 计算两个日期之间的工作日数?

c# - 根据绑定(bind)源中的外键显示查找值

c++ - 如何启用 VS2013 c++ 编译器功能?

c++ - 如何将png资源加载到对话框上的图片控件中?

android - Xamarin.Android 检测模拟器

android - 我如何在android中绘制一条真正的虚线