I've been playing around with SVG support in Android and came up with this library which claims that it supports SVG just as it they were native.
Since I took great pains in discovering that this is not really possible, I went to see how this dude actually managed it. So I came upon his Resources
derivative in which he declares a method (loadDrawable
) that has default visibility in base Resources class.
The funny thing is, normally lint would just report that you can't write this method since it would hide base method, but in this particular case (note the absense of @Override
directive) this method gets to be called as if it were written in the base class. All the methods invoking this method will invoke the override instead of original method. For me coming from classic compilers such as C++
or Pascal
, this is totally beyond comprehension.
Based on this, I managed to get my SVG support working completely with one single use of reflection and am super-happy about this, but:
Why does this work?