繁体   English   中英

在包“android”中找不到属性“layout_columnWeight”的资源标识符

[英]No resource identifier found for attribute 'layout_columnWeight' in package 'android'

错误:(25)在包“android”中找不到属性“layout_columnWeight”的资源标识符....

我无法在我的 xml 中更新它..它出现在我使用网格布局时..

 <GridLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/textView"
    android:layout_toEndOf="@+id/textView">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button"
        android:layout_columnWeight="0"
        />
   </GridLayout>

如果您想将GridLayoutcolumnWeight属性一起使用,最好的方法是使用 v7 支持版本。

<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/textView"
    android:layout_toEndOf="@+id/textView">


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button"
        app:layout_columnWeight="0"
        />
   </GridLayout>

请记住,如果你想使用这个 v7.widget.GridLayout 你必须导入这个库,将compile 'com.android.support:gridlayout-v7:23.1.1'添加到 gradle

在 API 21 之前,GridLayout 不支持weight 。如果您希望支持它,您可能需要使用支持库 v7 中的 GridLayout。 或者切换到 GridView。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM