Android GridLayout V7 的支持

  • Android,google,gridlayout,
  • 2020.08.27

2020.08.27 更新:事实证明,GridLayout 其实并不那么好用,在实际项目中几乎很少去使用到它。

Android4.0 增加了一个 GridLayout , 对于 4.0 之前的版本,如果要使用 GridLayout ,可以使用 google 提供的 android.support.v7.widget.GridLayout , 这是一个项目,在你的 sdk 目录下 sdk_folder\extras\android\compatibility\v7\gridlayout

Library Project including GridLayout.

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

按我的理解,这个可以被当成一个Android project使用,用来为API 7 以上的版本提供GridLayout的支持。

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 .

项目的src目录是空的,但是是必须的,不然会运行不起来。真正的代码被放在了 libs 下的 jar 包里了。

USAGE:

Make sure you use in your layouts instead of <gridlayout>. Same for <android.support.v7.widget.space> instead of <space>. <android.support.v7.widget.gridlayout>而不是<gridlayout>。

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.

要注意命名空间的问题。例子里有,注意看readme.txt

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

哪些参数可以使用,参考 res/values/attrs.xml

总的来说,到目前为止的所有试验的结果是,这个只能当成项目,导入到你的workspace里,导入后,这个项目默认是一个library项目,可以看项目下的project.properties文件,里面有这么几行:

# Project target.
target=android-7
android.library=true

然后再你想使用GridLayout的项目里,引入这个项目作为库。 具体步骤参考 http://developer.android.com/tools/projects/projects-eclipse.html 有图有真相有英文。

我尝试把这个GridLayout当成一个jar包导入到我的项目里,到目前为止是没有成功的。在网上找到 GridLayout 的源码,但是不是全部的。

相关文章

- EOF -

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处,尊重他人劳动。
转载请注明:文章转载自 Binkery 技术博客 [https://binkery.com]
本文标题: Android GridLayout V7 的支持
本文地址: https://binkery.com/archives/2020.08.27-android-gridlayout-v7-support.html