微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Xamarin.Android Layout_columnWeight 不能设置为 1

如何解决Xamarin.Android Layout_columnWeight 不能设置为 1

我想在 Xamarin.Andoird 中制作 2x2 布局。在另一个线程中,我发现这个代码可以做到这一点。但是当我把它放到我的 .xml 文件中时,我得到了 android:layout_columnWeight="1" 需要一个单位的错误。当设置为 1 时,预览显示正确的内容,但没有单元我无法编译。

<GridLayout
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="2"
>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button"
    android:layout_gravity="fill"
    android:layout_columnWeight="1"
    />

   <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button"
    android:layout_gravity="fill"
    android:layout_columnWeight="1"
    />

   <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button"
    android:layout_gravity="fill"
    android:layout_columnWeight="1"
    />

   <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button"
    android:layout_gravity="fill"
    android:layout_columnWeight="1"
    />

</GridLayout>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。