在Android 2.0的网格布局? [英] GridLayout in Android 2.0?

查看:112
本文介绍了在Android 2.0的网格布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个布局它类似于一个网格布局,但我克制到Android 2.0

I am trying to make a layout which resembles a Grid Layout, but I am restrained to Android 2.0

有没有人有什么想法?

<?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="wrap_content"
    android:columnCount="2"
    android:rowCount="13" >

    <TextView
        android:layout_gravity="fill_horizontal"
        android:text="SN : " />

    <TextView
        android:id="@+id/snTextView"
        android:layout_gravity="fill_horizontal" />


    <TextView
        android:layout_gravity="fill_horizontal"
        android:text="Ver : " />

    <TextView
        android:id="@+id/verTextView"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:layout_gravity="fill_horizontal"
        android:text="Type : " />

    <TextView
        android:id="@+id/typeTextView"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:layout_gravity="fill_horizontal"
        android:text="OD : " />

    <TextView
        android:id="@+id/odTextView"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:text="Closing Mode"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:id="@+id/closingModeTextView"
        android:layout_gravity="fill_horizontal" />

    <TextView
        android:text="CT : "
        android:layout_gravity="fill_horizontal" />

</GridLayout>

编辑:

嗯,我已经开始在.xml文件编码大约半小时前,我会发布上述code。要了解它的第一部分看,我去了图形布局,并出现以下错误想出了...

hmm, I had began coding about half an hour ago in the .xml file, I'll post the code above. To see how the first part of it looked, I went to the Graphical Layout, and the following error came up...

com.android.layoutlib.bridge.MockView不能转换为android.view.ViewGroup异常详细信息记录在窗口>显示视图>错误日志 以下类不能被找到:   - 网格布局(修正构建路径,编辑XML)

"com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup Exception details are logged in Window>Show View> Error Log The following classes could not be found: - GridLayout( Fix Build Path, Edit XML )"

我想这可能是别的东西是错误的,但在图形布局调色板网格布局还没有上市,而其中的其余都是(线性(垂直/ HOZ),相对的,帧,碎片,表等)

I guess it may be that something else is wrong, but in the Graphical Layout pallete GridLayout is not listed, while the rest of them are( Linear(vert/hoz), Relative, Frame, Fragment, Table, etc. )

推荐答案

网​​格布局已回迁到与API 7级及以上兼容。这是支持库(在某种程度上)的一部分。在您下载的支持库,你会发现在当地的SDK文件夹一个Android库项目位于:

GridLayout has been backported to be compatible with API level 7 and up. It's (sort of) part of the support library. After you've downloaded the support library, you'll find an Android library project in your local sdk folder located at:

<sdk_folder>\extras\android\compatibility\v7\gridlayout

将它设置为你工作项目的依赖。在这之后,你需要确保你在整个项目指向任何引用这一项,而不是15级的版本,以支持pre-ICS设备。用法应该是相似的,如果不相同。

Set it up as dependency of the project you're working on. After that, you'll need to make sure you point any references throughout your project to this one, and not the level 15 version, in order to support pre-ICS devices. Usage should be similar, if not identical.

另请参阅:网格布局支持Android的API 10

这篇关于在Android 2.0的网格布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆