I am trying to display a GridView in a Dialog. Despite all my efforts, the GridView width grows to the entire screen, instead of wrapping to the columns. The layout and an
I know that this post is a bit outdated. But if someone needs a solution to this, this answer may come in handy.
It is possible to set the view's width after screen measurement.
To do this:
Let your class implement the OnGlobalLayoutListener. The screen is measured when the onGlobalLayout method is called. We can do our magic here. GridView.getLayoutParams().width = ....
edit: I wasn't very clear on how to add the onGlobalLayoutListener. See plugmind's post, he shows how to add it. Can't figure out how to get view/layout width/height
Kind regards, Bram