I'm not sure if this is needed, it should be possible to check if this is a linear, relative or frame layout using instanceof and then do what ever is needed