blob: 56595016cbb99c9562e0738b624cfca384800c0c [file] [log] [blame] [view]
Eric Holkc4239ac2018-09-05 10:43:31 -07001# View Compiler
2
3This directory contains an experimental compiler for layout files.
4
5It will take a layout XML file and produce a CompiledLayout.java file with a
6specialized layout inflation function.
7
8To use it, let's assume you had a layout in `my_layout.xml` and your app was in
9the Java language package `com.example.myapp`. Run the following command:
10
11 viewcompiler my_layout.xml --package com.example.myapp --out CompiledView.java
12
13This will produce a `CompiledView.java`, which can then be compiled into your
14Android app. Then to use it, in places where you would have inflated
15`R.layouts.my_layout`, instead call `CompiledView.inflate`.
16
17Precompiling views like this generally improves the time needed to inflate them.
18
19This tool is still in its early stages and has a number of limitations.
20* Currently only one layout can be compiled at a time.
21* `merge` and `include` nodes are not supported.
22* View compilation is a manual process that requires code changes in the
23 application.
24* This only works for apps that do not use a custom layout inflater.
25* Other limitations yet to be discovered.