簡體   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