English | 中文
这是一个Android插件,通过在编译期时解析布局xml文件,将LayoutInflater中的反射实例化转成普通的实例化,以此来提高布局加载的性能
- 打开
setting.gradle文件,确保配置了远程仓库gradlePluginPortal和mavenCentral
pluginManagement {
repositories {
gradlePluginPortal()
mavenLocal()
// 其他仓库
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
mavenLocal()
// 其他仓库
}
}- 打开项目
build.gradle文件,在plugins下添加FastInflate插件
plugins {
id 'com.dreamgyf.android.fastinflate' version '0.1.0-alpha-07' apply false
}- 打开模块
build.gradle文件,在plugins下添加FastInflate插件
plugins {
id 'com.dreamgyf.android.fastinflate'
}- 打开模块
build.gradle文件,在dependencies下添加FastInflate库依赖
dependencies {
implementation 'com.dreamgyf.android.fastinflate:0.1.0-alpha-07'
}使用FastInflate替代LayoutInflater即可
// LayoutInflater.from(this).inflate(R.layout.activity_main, null)
FastInflate.from(this).inflate(R.layout.activity_main, null)-
<include />标签不支持使用theme属性 -
当前版本为
alpha测试版,尚未对所有Android版本进行兼容性测试
修复context问题后,性能降至和LayoutInflater相当的水平,后续想办法再提高性能
本项目使用 Apache-2.0 协议
