• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Library Project including GridLayout.
2
3This can be used by an Android project to provide
4access to GridLayout on applications running on API 7+
5
6There is technically no source, but the src folder is necessary
7to ensure that the build system works. The content is actually
8located in libs/android-support-v7-gridlayout.jar
9
10
11USAGE:
12
13Make sure you use <android.support.v7.widget.GridLayout> in your
14layouts instead of <GridLayout>.
15Same for <android.support.v7.widget.Space> instead of <Space>.
16
17Additionally, all of GridLayout's attributes should be put in the
18namespace of the app, as those attributes have been redefined in
19the library so that it can run on older platforms that don't offer
20those attributes in their namespace.
21
22To know which attributes need the application namespace, look at
23the two declare-styleable declared in res/values/attrs.xml
24
25
26
27For instance:
28
29<?xml version="1.0" encoding="utf-8"?>
30<android.support.v7.widget.GridLayout
31    xmlns:android="http://schemas.android.com/apk/res/android"
32    xmlns:app="http://schemas.android.com/apk/res-auto"  <==== the namespace used for the library project
33    android:layout_width="match_parent"
34    android:layout_height="match_parent"
35    app:columnCount="6" >                                <===== notice how we're using app:columnCount here, not android:columnCount!
36
37    <Button
38        android:id="@+id/button1"
39        app:layout_column="1"                            <=== again, note the app: namespace
40        app:layout_columnSpan="2"
41        app:layout_gravity="left"
42        app:layout_row="1"
43        android:text="Button" />
44
45    <CheckBox
46        android:id="@+id/checkBox1"
47        app:layout_column="4"
48        app:layout_gravity="left"
49        app:layout_row="2"
50        android:text="CheckBox" />
51
52    <Button
53        android:id="@+id/button2"
54        app:layout_column="5"
55        app:layout_gravity="left"
56        app:layout_row="3"
57        android:text="Button" />
58
59    <android.support.v7.widget.Space                    <=== space widgets also need the full support package path
60        android:layout_width="21dp"                     <=== use the android namespace for width, height etc -- only use app: for the grid layout library's new resources
61        android:layout_height="1dp"
62        app:layout_column="0"
63        app:layout_gravity="fill_horizontal"
64        app:layout_row="0" />
65
66