Search code examples
androidandroid-gridview

Is it safe to use GridView in Android?


So I know GridView is deprecated, but is it okay to use GridView for production code?

I would like to use it for my game app.

The Android Studio client says it has been deprecated in favor of ConstraintLayout, but trying to set up a grid (which should be a very simple, straightforward task) is such a hassle using ConstraintLayout.


Solution

  • So I know GridView is depreciated

    GridView is not deprecated, according to the JavaDocs

    The Android Studio client says it has been depreciated in favor of ConstraintLayout

    GridView and ConstraintLayout are not equivalent things, so that recommendation does not make sense.

    GridLayout is comparable to ConstraintLayout. GridLayout is also not deprecated.

    but is it okay to use GridView for production code?

    Both GridView and GridLayout are safe for use in production code. They are obsolete, and I would not recommend that anyone use them, but they are safe.

    • If what you want is a scrollable container of items in a grid, you can use GridView, though RecyclerView and GridLayoutManager would be a better choice

    • If what you want is a non-scrollable container of items in a grid, you can use GridLayout or perhaps TableLayout, though ConstraintLayout would be a better choice