ActionBarSherlock con icono Drawable personalizado que tiene un gran ancho/alto intrínseco; parece demasiado grande

Estoy usando una costumbre Drawable class to provide icons for my ActionBarSherlock. La costumbre Drawable clase, SVGDrawable, is actually part of my own SVG library. I've developed this library for other areas of this application, but I'm finding it useful to create ActionBar icons in SVG format too, because it avoids having to generate multiple images to support various densities. So, for the purpose of this question, the SVG stuff isn't really relevant. All that is relevant is that SVGDrawable renders content based on the contents of an .svg file, and that the intrinsic width / height is considered to be the original .svg document's width and height.

It all works perfectly well, except for the one small issue in that the SVGDrawable se le pide a draw() its image using the intrinsic width and height, rather than some width and height that fits within the ActionBarSherlock. SVGDrawable's getIntrinsicHeight() returns the original height of the SVG document (and the same goes for the width), and therefore if for instance the original SVD document is 300px square, then that's what the SVGDrawable will be rendered at.

Supongo que el ActionBarSherlock basically wants its icon Drawables to draw at their own intrinsic sizes, because in the usual case you would use image resource drawables, and those drawables would have already been authoried to be exactly the correct sizes for the various densities.

Initially, I wrongly assumed that the SVGDrawables setBounds() would be called with some values that state how large the ActionBarSherlock permits the icon to be.

For my situation, the only work-around I can think of is to add a method like setIntrinsicDimensions(int width, int height) which would basically override the dimensions read from the original SVG document. I suppose that, when adding the SVGDrawable programmatically to the ActionBarSherlock, I would also call this method and supply a suitable width and height, where the height is the height of the ActionBarSherlock minus some padding.

Any better approach, anyone?

preguntado el 05 de mayo de 13 a las 13:05

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.