I have this code:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="8"
android:rowCount="8" >
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
<ImageButton
android:src="@android:drawable/ic_menu_rotate"
android:contentDescription="@null" />
</GridLayout>
And its giving me this:
Its supposed to be an 8x8 grid but it's overflowing. How can I, non-programmatically, (through xml) fit the 64 squares?
GridView and ConstraintLayout are not equivalent things, so that recommendation does not make sense. GridLayout is comparable to ConstraintLayout . GridLayout is also not deprecated.
GridView simply gives us a two-dimensional view to display the items on the screen, under ViewGroup. On the other hand, GridLayout is a layout manager that arranges the views in a grid.
When you add item to grid layout, depend on Column count Grid layout will start to scroll.
Android GridLayout is used to display elements and views in the form of a rectangular grid. GirdLayout and GridView are two completely different terms and are used for other purposes. GridView is a view, whereas GridLayout is a layout that can hold various views in it.
you might also want to checkout http://daniel-codes.blogspot.com.au/2012/01/gridlayout-view-clipping-issues.html
here's the key info from that page incase it get's deleted:
use the following in you last (right most) view
android:layout_width="0dip"
android:layout_gravity="fill_horizontal"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With