You have to make sure not just to use
<android.support.v7.widget.GridLayout> for the layout itself, but you have
to use the app namespace for all of its attributes too, since "layout_row",
"rowCount" etc are not defined in the android namespace for versions older
than API 14. As of ADT 17 there's improved handling for library project
resource namespaces ("res-auto"), so your layout should look something like
this:
<?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" />
...
-- Tor
On Thursday, April 5, 2012 7:56:37 AM UTC-7, Siddharth Menon wrote:
>
> Thanks Tor
>
> I tried using *<android.support.v7.widget.GridLayout>* gives me no error
> but I will not render as grid.
> Has anybody successfully got this working?
>
> On Wednesday, April 4, 2012 6:56:48 PM UTC+5:30, Tor Norbye wrote:
>>
>> You need to use <android.support.v7.widget.GridLayout>.
>>
>> -- Tor
>>
>> On Wed, Apr 4, 2012 at 5:02 AM, Siddharth Menon
>>
>> > Hi,
>> >
>> > So finally give GridLayout support for older version.
>> >
>> > Added GridLayout project from <sdk>/extras/android/support/v7/gridlayout
>> > Added this project as lib to my working project (Target API 7 to 15)
>> > Now in the XML when I use <GridLayout> or <android.widget.GridLayout> I
>> get
>> > the following error
>> >
>> > GridLayout (Change to android.widget.GridLayout, Fix Build Path, Edit
>> XML)
>> >
>> > Can somebody please guide me what is that I am doing wrong?
>> >
>> >
>> > Cheers
>> > Siddharth Menon
>> >
>> >
>> > On Friday, March 23, 2012 12:36:16 AM UTC+5:30, André Luiz R. Silva
>> wrote:
>> >>
>> >> Someone use GridLayout (ADT-17) in v7?
>> >>
>> >> Errors:
>> >> [GridLayoutTest] ERROR: In <declare-styleable> GridLayout_Layout,
>> unable
>> >> to find attribute android:layout_marginEnd
>> >> [GridLayoutTest] ERROR: In <declare-styleable> GridLayout_Layout,
>> unable
>> >> to find attribute android:layout_marginStart
>> >>
>> >> Use <sdk>/extras/android/support/v7/gridlayout.
>> >>
>> >> --
>> >> Atenciosamente,
>> >>
>> >> André Luiz R. Silva
>> >> @andreronsilva
>> >>
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Android Developers" group.
>> > To post to this group, send email to
>> [email protected]
>> > To unsubscribe from this group, send email to
>> > [email protected]
>> > For more options, visit this group at
>> > http://groups.google.com/group/android-developers?hl=en
>>
>>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en