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.

1
  • use recyclerview with gridlayout manager Commented Jul 26, 2019 at 18:50

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

6 Comments

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?
@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".
what the better is? can you please explain it? I know I can use constraintLayout but the apk size will increase right? if I use GridView then it will keep small size thank you I am newbie so I want to ask it
@liang.good: "what the better is?" -- I cover that in the answer. In particular, please read the two bullets at the end, where I provide specific recommendations. Since I wrote this in 2019, Jetpack Compose has become a major UI toolkit for Android, and there are composables that offer similar functionality. "I know I can use constraintLayout but the apk size will increase right?" -- it will not increase very much. "if I use GridView then it will keep small size" -- GridView and ConstraintLayout are not equivalent sorts of containers.
according my search Jetpack Compose is for kotlin right? If I do not use kotlin then better not use Jetpack Compose?
|