Android LayoutInflater: inflate Binary layout xml

327 views Asked by At

I am trying to dynamically inflate an layout xml file. The file should later come from a server so the Android app (client) will download it and load the layout.

I know that its impossible to do this with a plain layout file because for performance reasons the layout xml is somehow converted before and the LayoutInflater only works with some sort of binary Xml.

Now my question. Would it be possible to convert the "normal" layout xml file into a binary xml file on the server and then send it to the client so the LayoutInflater can load the binary xml from the server?

Thanks for any help in advance

1

There are 1 answers

0
Vladimir Davidovich On

Yes, it is possible. But you'll have to create android.view.ContextThemeWrapper subclass and use 2 private methods of Android framework:

  1. android.content.res.AssetManager constructor
  2. android.content.res.AssetManager.addAssetPath