1

How do I dynamically set the height of a cell in GridView, and how do I refresh it? Right now, I have my Adapter implement OnGlobalLayoutListener, get the dimensions of my GridView when onGlobalLayout is called, then save the dimensions. In getView(), I call cell.setLayoutParams(mGridViewWidth / 3, mGridViewWidth / 3); My problem is that my entire GridView is pushed too much to the left so only part of the last column is visible. Calling notifyDataChanged() seems to work, but it looks inefficient. I tried mGridView.requestLayout() and mGridView.invalidateViews() but those didn't work.

I confirmed that my GridView takes up the entire screen as it should. It's the elements that are positioned weird. I set my GridView's background color to #0000ff and the screen was blue. There's something wrong with the elements. Is it wrong for me to recycle LayoutParams?

cesar
  • 8,944
  • 12
  • 46
  • 59

1 Answers1

1

Apparently using android:stretchMode="none" destroys the GridView. It works now that I removed that bit of code.

cesar
  • 8,944
  • 12
  • 46
  • 59