简体   繁体   中英

No resource identifier found for attribute 'layout_columnWeight' in package 'android'

Error:(25) No resource identifier found for attribute 'layout_columnWeight' in package 'android'....

i am not able to update it in my xml ..it arose when i was working with grid layout ..

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

If you want to use GridLayout with columnWeight property the best way is to use v7 support version.

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

Remember that if you want to use this v7.widget.GridLayout you must import this library adding compile 'com.android.support:gridlayout-v7:23.1.1' to gradle

weight is not supported by GridLayout until API 21. If you want it to be supported, you might want to use GridLayout from support library v7. Or switch to GridView.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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