Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android gridlayout overflowing screen

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:

enter image description here

Its supposed to be an 8x8 grid but it's overflowing. How can I, non-programmatically, (through xml) fit the 64 squares?

like image 495
Ogen Avatar asked Oct 31 '13 08:10

Ogen


People also ask

Is GridLayout deprecated?

GridView and ConstraintLayout are not equivalent things, so that recommendation does not make sense. GridLayout is comparable to ConstraintLayout . GridLayout is also not deprecated.

What is the difference between GridView and GridLayout in Android?

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.

Is GridLayout scrollable?

When you add item to grid layout, depend on Column count Grid layout will start to scroll.

What is GridLayout Android studio?

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.


1 Answers

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"
like image 161
SteelBytes Avatar answered Oct 28 '22 08:10

SteelBytes