我正在尝试实现etsy Staggered GridView,但不幸的是我可以让我的布局正常工作。这是xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bgg"
android:orientation="vertical">
<com.etsy.android.grid.StaggeredGridView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/gvgrigview"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipChildren="true"
android:cacheColorHint="@android:color/transparent"
android:background="@android:color/transparent"
android:fastScrollEnabled="true"
app:item_margin="2dp"
app:column_count="@integer/grid_column_count">
</com.etsy.android.grid.StaggeredGridView>
</LinearLayout>
答案 0 :(得分:2)
在xml的根布局中,你必须添加:xmlns:staggered =“http://schemas.android.com/apk/res-auto”
答案 1 :(得分:0)
删除mlns:app="http://schemas.android.com/apk/res-auto"
。只需
<com.etsy.android.grid.StaggeredGridView
android:id="@+id/gvgrigview"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipChildren="true"
android:cacheColorHint="@android:color/transparent"
android:background="@android:color/transparent"
android:fastScrollEnabled="true"
app:item_margin="2dp"
app:column_count="@integer/grid_column_count">
</com.etsy.android.grid.StaggeredGridView>
编辑:
查看您引用的那个在xml
的根元素中缺少以下内容 xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"