tree: d2287956250d835042f2419f2a8caea2e850ad69 [path history] [tgz]
  1. Android.bp
  2. java_lang_builder.cc
  3. java_lang_builder.h
  4. main.cc
  5. README.md
  6. TEST_MAPPING
  7. util.cc
  8. util.h
  9. util_test.cc
startop/tools/view_compiler/README.md

View Compiler

This directory contains an experimental compiler for layout files.

It will take a layout XML file and produce a CompiledLayout.java file with a specialized layout inflation function.

To use it, let's assume you had a layout in my_layout.xml and your app was in the Java language package com.example.myapp. Run the following command:

viewcompiler my_layout.xml --package com.example.myapp --out CompiledView.java

This will produce a CompiledView.java, which can then be compiled into your Android app. Then to use it, in places where you would have inflated R.layouts.my_layout, instead call CompiledView.inflate.

Precompiling views like this generally improves the time needed to inflate them.

This tool is still in its early stages and has a number of limitations.

  • Currently only one layout can be compiled at a time.
  • merge and include nodes are not supported.
  • View compilation is a manual process that requires code changes in the application.
  • This only works for apps that do not use a custom layout inflater.
  • Other limitations yet to be discovered.