11 ms·
> XML is parsed on the device wasting CPU time and battery It was my understanding the XML was compiled into a binary format for faster parsing on device, am I
by jarofgreen 11y ago
> XML is parsed on the device wasting CPU time and battery
It was my understanding the XML was compiled into a binary format for faster parsing on device, am I wrong on that?
EDIT:
http://en.wikipedia.org/wiki/Android_application_package http://en.wikipedia.org/wiki/Android_application_package "resources.arsc: a file containing precompiled resources, such as binary XML for example." Ah yes, I think it does.
> Most of all, it allows no code reuse.
If we are talking code reuse in terms of having one common bit of layout that is used across several different layouts, actually you can: http://developer.android.com/training/improving-layouts/reusing-layouts.html http://developer.android.com/training/improving-layouts/reus...
Also, the Android view system as it stands is incredible flexible.
You can provide different layouts and style rules for different screensizes and device configs - an kinda equivalent to the webs responsive design using CSS media queries.
Also, every view component is just a Java class. As well as allowing you to create your own class from scratch that you can just use as part of a view, you can also extend an existing view class and just change one bit of it's behaviour.
I don't especially mean to have a go at Anko - sorry. It's just that I think the Android views are actually pretty good, and certainly when I'm working on Android apps this isn't one of the major problems I have!
- deleted 11y ago[deleted]
- frik 11y ago> resources.arsc: a file containing precompiled resources, such as binary XML for example yes, SO answer: http://stackoverflow.com/a/6646113 http://stackoverflow.com/a/6646113
- EddieRingle 11y ago> It was my understanding the XML was compiled into a binary format for faster parsing on device, am I wrong on that? That's correct, but it still requires the additional overhead of parsing the compiled resources and using reflection to instantiate Views. Anko instantiates Views directly.
- jarofgreen 11y agoSo, Anko builds views up dynamically in Java only? Interesting - is there any stats on how much faster this actually is?
- madisp 11y agoActually resources.arsc only contains the resource table (think stuff in values/ folders, like strings.xml). The layouts still have their own xml files in res/layout. It is in Android's XML chunk format though, not plain-text xml. Interesting point - the resource table still has references to the XML files for configuration-resolving purposes, but they are only strings. E.g. getString(R.layout.main) will actually work and return "res/layout/main.xml" or "res/layout-land/main.xml" depending on the device configuration (and assuming one has the layout-land version). Vice-versa, if you have a string resource with the value "res/layout/main.xml" and say, name foo, then calling setContentView(R.string.foo) actually works.