How do I specify width and height of Android GridLayout cells in relative measures?

前端 未结 5 1870
自闭症患者
自闭症患者 2020-12-13 13:01

I\'m trying to figure out how GridLayout works, but one thing I can\'t figure out from the documentation is how or if one can control the size of the grid cells.

Sa

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 13:10

    it looks like setting it as you'd like should be fairly straightforward according to the documentation:

    android:rowCount='2'
    android:columnCount='2'
    

    and in the children set

    android:layout_columnSpan="1"
    android:layout_rowSpan="1"
    

    This reference also mentions stretching:

    To prevent a column from stretching, ensure that one of the components in the column does not define a gravity.

    Which would seem like a solution to keep the rows and columns in a 50:50 ratio without resizing according to content

提交回复
热议问题