English | 中文
This is an Android plugin, which can improve the performance of layout loading by parsing the layout xml file during the compilation period and converting the reflection instantiation in LayoutInflater into a normal instantiation.
- Open the
setting.gradle
file, and make sure that the repositories,gradlePluginPortal
andmavenCentral
, are configured.
pluginManagement {
repositories {
gradlePluginPortal()
mavenLocal()
// other repository
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
mavenLocal()
// other repository
}
}
- Open the
build.gradle
file of project, and add theFastInflate
plugin in theplugins
.
plugins {
id 'com.dreamgyf.android.fastinflate' version '0.1.0-alpha-07' apply false
}
- Open the
build.gradle
file of module, and add theFastInflate
plugin in theplugins
.
plugins {
id 'com.dreamgyf.android.fastinflate'
}
- Open the
build.gradle
file of module, and add theFastInflate
library in thedependencies
.
dependencies {
implementation 'com.dreamgyf.android.fastinflate:0.1.0-alpha-07'
}
Just use FastInflate
instead LayoutInflater
.
// LayoutInflater.from(this).inflate(R.layout.activity_main, null)
FastInflate.from(this).inflate(R.layout.activity_main, null)
-
The
<include />
tag doesn't supported to usetheme
attribute. -
The current version is an alpha beta, and have not done compatibility tests for all of the Android versions.
After fixing the context problem, the performance drops to the same level as that of the LayoutInflater.
I'll find ways to improve performance in the future.
This project uses the Apache-2.0 license.