tree: 9c6ce5c5da406ebba7687d4c752298281d1221f3 [path history] [tgz]
  1. Android.bp
  2. dex_builder.cc
  3. dex_builder.h
  4. dex_builder_test.cc
  5. java_lang_builder.cc
  6. java_lang_builder.h
  7. main.cc
  8. README.md
  9. TEST_MAPPING
  10. util.cc
  11. util.h
  12. util_test.cc
startop/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.