Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually pre-compile xml layout files and use them

Tags:

android

Is it possible to manually pre-compile a layout file, put it in a jar and use it? if possible how ?

I'll explain: When using a apk packaging, the build process pre compile xml resources, for runtime optimization. Let's say, for example, I want to load xml files from a server, and load them to ui. I need to pre-compile them, and I prefer doing it on server side with the android sdk.

like image 269
Chen Kinnrot Avatar asked May 20 '12 06:05

Chen Kinnrot


People also ask

What is the use of XML in Android?

XML tags define the data and used to store and organize data. It's easily scalable and simple to develop. In Android, the XML is used to implement UI-related data, and it's a lightweight markup language that doesn't make layout heavy. XML only contains tags, while implementing they need to be just invoked.

Where are the XML layout files stored?

Specifically, Android considers XML-based layouts to be resources, and as such, layout files are stored in the reslayout directory inside your Android project. Each XML file contains a tree of elements specifying a layout of widgets and containers that make up one View.

Why layouts are created using XML file?

Using Android's XML vocabulary, you can quickly design UI layouts and the screen elements they contain, in the same way you create web pages in HTML — with a series of nested elements. Each layout file must contain exactly one root element, which must be a View or ViewGroup object.

How many layout XML files can be associated with an activity?

You can not provide more than one layout to any activity, but if you want to use the different layout files in one activity than you can include all layout files into a single layout file using tag and use them in you activity.


1 Answers

try this:

  1. put your xml file into your resource folder (for example into res/xml)
  2. run your project
  3. go to bin folder of your project
  4. open youapplication.apk as zip-archive
  5. go to res/xml folder of your archive
  6. extract already compiled xml from that folder
  7. use extracted xml as your complied xml file
like image 196
pleerock Avatar answered Sep 23 '22 23:09

pleerock