Background and wrap-content

I am currently looking for other options to place advertising, to gain a little usability. Like those of you that use the application already know, advertising appears just above the station switcher, and because it appears a few seconds after starting the application, through an animation, it is not difficult to click it by mistake when trying to change the station.
My original idea had always been to place advertising on the bottom, where is less annoying, but in the first version I had to discard it because I could not get it on time.
Now I finally know why it had not worked, and I take this opportunity to share the solution with others, as it involves some tricky layout properties. The fact is that if you use the “wrap_content” mode in some dimension of a widget layout, the automatic size that the widget will take, not only expands to the children size, but also to the image you may set as background. In my case, the image was too large, since it had not been designed with the idea of including advertising, and therefore the “wrap_content” mode expanded the main component until it did not left room for the advertising.
In addition, another side effect showed up. Since android resolutions are not exactly proportional, not to mention the space left under the otempo station switcher, I was forced to provide background versions with slightly different proportions for each android density, to leave the exact room for the advertising. This, unfortunately, slightly increases the size of the application.


Acerca de Rubén L.

Software Engineer
Esta entrada fue publicada en android, English y etiquetada , , . Guarda el enlace permanente.


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s