Closed GoogleCodeExporter closed 9 years ago
Hi Rod
Can you include a snippet of code to show me how you are adding the
SVGImageView?
Thanks
Paul
Original comment by paul.leb...@gmail.com
on 19 Nov 2013 at 8:05
Paul,
You sir, are a scholar and a gentlemen.
I will do this, this evening when I get back to the hotel. I apologize
again, for not putting it directly in the request, as I was pressed for
time this morning and hoping something might ring a bell.
One question, if using an SVGImageView, do I still need to set that
SOFTWARE layer option
in order to get the image to render? Just curious. As I may look into
attempting to get a bitmap of specific dimensions, out of the SVG, and
just working with that directly, so that I can use the hardware
acceleration.
Thanks, for the speedy reply. I will include details this evening.
Original comment by rod.mcel...@gmail.com
on 19 Nov 2013 at 8:09
At the moment, the SVGImageView uses the renderToPicture() method for rendering
the SVG. So yes, it is limited to software rendering. But the software
rendering mode is set automatically by SVGImageView, so you don't have to do it
yourself.
A future version of SVGImageView will add the option of renderToCanvas() for
hardware rendering.
In case you haven't already seen it, the following page has more info on using
the custom view: http://code.google.com/p/androidsvg/wiki/SVGImageView
Original comment by paul.leb...@gmail.com
on 19 Nov 2013 at 8:25
Paul,
OK, I had left my micro-usb cable at home, and so I was running the
emulator. This is where I received the static field error. I borrowed a
usb cable at work. And running on a 2013 Nexus 7, I am not seeing this
message any longer. However, I'm not seeing a rendered image either.
Here is some sample code.
LookViewSVGImageView extends SVGImageView
Below is the relevent code fragment. I am using a RelativeLayout which
is different from your example.
I am attempting to animate the alpha setting but for debugging, I've
left it at 1.0f.
lv = new LookViewSVGImageView(this.m_context);
((SVGImageView) lv).setImageAsset(path);
RelativeLayout.LayoutParams lp = new
RelativeLayout.LayoutParams(height, width);
lp.leftMargin = left;
lp.topMargin = top;
lp.height = height;
lp.width = width;
lv.setTag(image.tag);
lv.setAlpha(1.0f);
lv.setAdjustViewBounds(false);
lv.setScaleType(ImageView.ScaleType.CENTER);
this.addView(lv,lp);
This particular fragment was working:
svg = SVG.getFromAsset(getContext().getAssets(), path);
Drawable drawable = new PictureDrawable(svg.renderToPicture());
lv.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
lv.setBackgroundColor(Color.WHITE);
lv.setImageDrawable(drawable);
I think you've done a great job with the library, but I'm reaching the
point where I think I might like
to get a Bitmap out of the process and work with that directly, as there
are additional transformations,
I'd like to do on it. Is that something that is easily doable?
Thanks for being so responsive. It is above and beyond. I do appreciate
your time.
Rod
Original comment by rod.mcel...@gmail.com
on 20 Nov 2013 at 1:12
Paul,
Ah - spoke too soon. Or missed it on the first run...
11-19 20:14:11.508: W/dalvikvm(14035): VFY: unable to resolve static
field 1107 (SVGImageView) in Lcom/caverock/androidsvg/R$styleable;
This is generate by the first code example, using a RelativeLayout on a
2013 Nexus 7. 4.4
I'll try dropping the scale type.
Original comment by rod.mcel...@gmail.com
on 20 Nov 2013 at 1:17
Paul,
Sorry for spamming you.
A couple of things. The SVG I'm working with is a pure black and white
image.
The background must be transparent, however. If I set the background
color to white.
lv.setBackgroundColor(Color.WHITE);
AND REMOVE this line:
lv.setScaleType(ImageView.ScaleType.CENTER);
Then I see the image, rendered. I still get the static reference not
found warning.
And the image is scaled to fit the available area in the view, while
maintaining the
aspect ratio. Which isn't exactly what I'm looking for, but at least it
starting to make some sense.
Original comment by rod.mcel...@gmail.com
on 20 Nov 2013 at 1:28
Rod
There are a couple of issues here:
(1) In your LayoutParams() constructor, you have width and height switched.
Although it doesn't actually matter because you override them later. :)
(2) It seems ScaleType.CENTER doesn't work here for some reason. I haven't
quite worked out why yet. However you can use ScaleType.CENTER_INSIDE instead.
Here's my code which worked fine:
RelativeLayout layout = (RelativeLayout) findViewById(R.id.top);
SVGImageView lv = new SVGImageView(this);
lv.setImageAsset("test.svg");
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(400, 400);
lp.leftMargin = 16;
lp.topMargin = 16;
lp.width = 700;
lp.height = 900;
//lv.setTag(image.tag);
lv.setAlpha(1.0f);
lv.setAdjustViewBounds(false);
lv.setBackgroundColor(Color.RED);
lv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
layout.addView(lv,lp);
(3) Lastly you may also be striking an issue with SVG width and height. If you
want your SVG images/icons to be a particular size, make sure you set them
explicitly in your file. For example:
<svg width="64" height="64" ...>
If the width and height are set to a percentage value, or are not specified
(meaning they default to "100%"):
<svg width="100%" height="100%" ...>
then AndroidSVG will produce an image at the default size, which is 512x512.
Which may be larger than your ImageView and so won't be centred.
Hope this helps. Let me know if you are still having problems.
Original comment by paul.leb...@gmail.com
on 21 Nov 2013 at 1:51
Marking this issue Wont Fix (nothing to fix).
This seems to be an issue related to using Picture with an ImageView.
Since this issue is not directly an AndroidSVG issue and there is a workaround,
it seems appropriate to close it.
@Rod: hopefully my response above was helpful in resolving your problem.
Original comment by paul.leb...@gmail.com
on 17 Dec 2013 at 12:20
Original issue reported on code.google.com by
rod.mcel...@gmail.com
on 19 Nov 2013 at 1:53