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.gradlefile, and make sure that the repositories,gradlePluginPortalandmavenCentral, are configured.
pluginManagement {
repositories {
gradlePluginPortal()
mavenLocal()
// other repository
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
mavenLocal()
// other repository
}
}- Open the
build.gradlefile of project, and add theFastInflateplugin in theplugins.
plugins {
id 'com.dreamgyf.android.fastinflate' version '0.1.0-alpha-07' apply false
}- Open the
build.gradlefile of module, and add theFastInflateplugin in theplugins.
plugins {
id 'com.dreamgyf.android.fastinflate'
}- Open the
build.gradlefile of module, and add theFastInflatelibrary 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 usethemeattribute. -
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.
