GridLayout

General

Category
Free
Tag
Layouts
License
N/A
Min SDK
7 (Android 2.1 Eclair)
Registered
Jul 5, 2014
Favorites
0
Link
https://github.com/jacobmoncur/gridlayout_v7
See also
DrawerBehavior
Cult
CameleonLayout
GradientLayout
Decor

Additional

Language
Java
Version
N/A
Created
Jan 11, 2013
Updated
Jan 11, 2013 (Retired)
Owner
Jacob Moncur (jacobmoncur)
Contributor
Jacob Moncur (jacobmoncur)
1
Activity
Badge
Generate
Download
Source code

Show card

Library Project including GridLayout.

This can be used by an Android project to provide
access to GridLayout on applications running on API 7+

There is technically no source, but the src folder is necessary
to ensure that the build system works. The content is actually
located in libs/android-support-v7-gridlayout.jar


USAGE:

Make sure you use <android.support.v7.widget.GridLayout> in your
layouts instead of <GridLayout>.
Same for <android.support.v7.widget.Space> instead of <Space>.

Additionally, all of GridLayout's attributes should be put in the
namespace of the app, as those attributes have been redefined in
the library so that it can run on older platforms that don't offer
those attributes in their namespace.

To know which attributes need the application namespace, look at
the two declare-styleable declared in res/values/attrs.xml



For instance:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"  <==== the namespace used for the library project
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:columnCount="6" >                                <===== notice how we're using app:columnCount here, not android:columnCount!

    <Button
        android:id="@+id/button1"
        app:layout_column="1"                            <=== again, note the app: namespace
        app:layout_columnSpan="2"
        app:layout_gravity="left"
        app:layout_row="1"
        android:text="Button" />

    <CheckBox
        android:id="@+id/checkBox1"
        app:layout_column="4"
        app:layout_gravity="left"
        app:layout_row="2"
        android:text="CheckBox" />

    <Button
        android:id="@+id/button2"
        app:layout_column="5"
        app:layout_gravity="left"
        app:layout_row="3"
        android:text="Button" />

    <android.support.v7.widget.Space                    <=== space widgets also need the full support package path
        android:layout_width="21dp"                     <=== use the android namespace for width, height etc -- only use app: for the grid layout library's new resources
        android:layout_height="1dp"
        app:layout_column="0"
        app:layout_gravity="fill_horizontal"
        app:layout_row="0" />