GridView VS GridLayout in Android Apps

旧时模样 提交于 2019-11-26 09:15:39

问题


I have to use a grid to implement Photo Browser in Android, and I want to know the difference between GridView and GridLayout.

I\'m using GridView to display the images dynamically.


回答1:


A GridView is a ViewGroup that displays items in two-dimensional scrolling grid. The items in the grid come from the ListAdapter associated with this view.

This is what you'd want to use (keep using). Because a GridView gets its data from a ListAdapter, the only data loaded in memory will be the one displayed on screen. GridViews, much like ListViews reuse and recycle their views for better performance.

Whereas a GridLayout is a layout that places its children in a rectangular grid.

It was introduced in API level 14, and was recently backported in the Support Library. Its main purpose is to solve alignment and performance problems in other layouts. Check out this tutorial if you want to learn more about GridLayout.



来源:https://stackoverflow.com/questions/11307218/gridview-vs-gridlayout-in-android-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!