5

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.

Community
  • 1
  • 1

1 Answers1

8

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

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 2
    You are contradicting yourself. First you say `GridView` and `GridLayout` are not deprecated, then you say they are both obsolete, but safe. Obsolete stuff is deprecated, so could you please clarify? – Martin Braun Apr 09 '21 at 12:23
  • 1
    @MartinBraun: "Obsolete stuff is deprecated" -- by "obsolete", I mean "the industry has moved on to better solutions". By "deprecated", I mean "the Android team has applied the `@Deprecated` annotation". – CommonsWare Apr 09 '21 at 12:24