其他分享
首页 > 其他分享> > android中的GridView和GridLayout

android中的GridView和GridLayout

作者:互联网

参见英文答案 > GridView VS GridLayout in Android Apps                                    1个
我试图在xml文件中添加GridView的子视图,但它给出了错误,并且它与GridLayout一起工作正常.所以我想知道..
在Android中有什么区别b / w GridView和GridLayout?

解决方法:

基本区别在于GridView是一个可滚动的视图,如ListView,而GridLayout是一个布局.两者看起来都一样,但GridView是可滚动的

根据GridView的文档,正式定义如下:

GridView

GridView is a ViewGroup that displays items in a two-dimensional,
scrollable grid. The grid items are automatically inserted to the
layout using a ListAdapter.

和GridLayout的定义,来自docs

GridLayout

A layout that places its children in a rectangular grid.

The grid is composed of a set of infinitely thin lines that separate
the viewing area into cells. Throughout the API, grid lines are
referenced by grid indices. A grid with N columns has N + 1 grid
indices that run from 0 through N inclusive. Regardless of how
GridLayout is configured, grid index 0 is fixed to the leading edge of
the container and grid index N is fixed to its trailing edge (after
padding is taken into account).

标签:android,android-layout,gridview,android-gridlayout
来源: https://codeday.me/bug/20190716/1477241.html