android-gridlayout

GridLayout (not GridView) how to stretch all children evenly

安稳与你 提交于 2019-11-26 03:14:59
问题 I want to have a 2x2 grid with a buttons inside. This is only ICS so I am trying to use the new GridLayout given. Here\'s the XML of my layout: <?xml version=\"1.0\" encoding=\"utf-8\"?> <GridLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:id=\"@+id/favorites_grid\" android:layout_width=\"match_parent\" android:layout_height=\"match_parent\" android:background=\"#00ff00\" android:rowCount=\"2\" android:columnCount=\"2\"> <Button android:text=\"Cell 0\" android

Android GridLayout with dynamic number of columns per row

谁说胖子不能爱 提交于 2019-11-26 00:55:56
问题 I have cards with different width and I would like to create a Grid Layout where width = match the parent (filling the screen) and fixed height. I would like to set the cards in the Grid layout so the number of columns changes accordingly to the width of the elements that can fit the row. So the elements will be set in a horizontal row till they can fit the screen and then go to the next row, with a vertical scroll when they exceed the fixed height. I am trying to use a Grid Layout but I don\