Learn about AX2J

About the AX2J

The idea of making AX2J was come out in 2014 at work. There was a demand that we need to provided jar files to the client which includes some UI and will be load at runtime. It need to be small enough so it can not relay on any framework. Because we can not inflate XML at runtime, it is a repeating work converting UI from XML to Java. So AX2J is born for this.

How it works

The XML-to-Java translation is based on a conversion table. The conversion table can handle various situations such as reflection assignment, LayoutParams assignment, multi-paramater assignment, priority assignment.

For example, a row "View,android:alpha,setAlpha(float)," means: for all the layout extends from View.class, the 'android:alpha' attribute will transfer to setAlpha(), and the value is type of float. In some situation, the XML attribute don't have directly Java method to translate. like 'View,android:layout_width,0x00410000', setting width of a view needs a LayoutParam object to make it effective by set into the View, which is marked by the flag 0x00410000.

Get Started

Content Translate

Content Translate is a XML block translator. Just paste your XML which described your view to the left side, then click "TRANSLATE", it will generate the relative Java code and package as a method. There is already a default sample to you.

Currently support view translation only.

Try it now!

Project Translate

Project Translate is a project translator. Compress your project to a .zip file and upload, the project translator will found out all the xml resources (included layout, values, drawable) and package them to a .jar file. After that you can use this .jar file to get all your xml resources directly.

Try it now!

About the Author

Chen Hao

Android developer

Shenzhen, China

Resume (Chinese): BOSS 直聘