I'm trying to find an easy way to AB test layout, note that the layouts that I'm talking about are minor changes in views width, height, text-size, margins... the main problem is that a single test that requires to change a few of those parameters requires me:
- Create duplicate layouts with just minor changes
- Or change those parameters after the view is inflated
I tried to implement a LayoutInflater.Factory
that will go over the XML attributes and override them in the following menor:
<View
android:layout_width="wrap_content"
android:layout_height="30dp"
override:layout_height="resolveHeightForABtest()"
/>
when the factory sees an override attribute, it overrides the original (calling the specified method via reflection).
The implementation is not that complex however, the original class that implements the LayoutInflater.Factory
interface, seems impossible to obtain the instance without reflection. (I need to delegate the view creation to this class. I don't want to reimplement it.
Any ideas on how it can be achieve? not necessarily the solution above, but anything that can simplify AB testing with multiple layouts could be awesome!