0

I'm working on a custom view that uses a GridLayout from the support library on Android. I've set app:columnCount="7" on the GridLayout. At runtime, I populate it with TextViews. Each of those has width/height of wrap_content and app:layout_columnWeight="1". The TextViews are setup in their onMeasure() to have the same width/height (Math.max(getMeasuredWidth(), getMeasuredHeight())).

What I end up with are 5 columns that are 133px and 2 columns that are 163px on a Nexus 5X instead of 7 columns that are each about 142px. For the life of me, I can't figure out why those 2 columns are so much larger and how to fix it.

Can anyone clue me in here?

Environment is:

  • Android Studio 2.3

  • Gradle Plugin 2.3.2

  • Gradle 3.4.1

  • Nexus 5X

  • Android O Preview 2 (though I've seen the same issue on Android 7.1.2)

MCLLC
  • 496
  • 4
  • 12
  • 1
    See my answer regarding Gridview https://stackoverflow.com/questions/40581947/adjust-gridview-with-imageviews-to-different-screen-sizes-android/40582403#40582403 – Vishal Senjaliya May 26 '17 at 13:26
  • @ERVishalSenjaliya the problem I ran into with GridView is that the height of the GridView is too small. It doesn't auto set the height to the size of all of its elements. I'd prefer to stick with GridLayout and just figure out how to force the column widths to match. – MCLLC May 26 '17 at 16:57

0 Answers0