Coder Social home page Coder Social logo

Comments (8)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 2, 2024
Hi Rod

Can you include a snippet of code to show me how you are adding the 
SVGImageView?

Thanks
Paul

Original comment by [email protected] on 19 Nov 2013 at 8:05

from androidsvg.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 2, 2024
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 [email protected] on 19 Nov 2013 at 8:09

from androidsvg.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 2, 2024
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 [email protected] on 19 Nov 2013 at 8:25

from androidsvg.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 2, 2024
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 [email protected] on 20 Nov 2013 at 1:12

from androidsvg.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 2, 2024
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 [email protected] on 20 Nov 2013 at 1:17

from androidsvg.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 2, 2024
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 [email protected] on 20 Nov 2013 at 1:28

from androidsvg.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 2, 2024
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 [email protected] on 21 Nov 2013 at 1:51

from androidsvg.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 2, 2024
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 [email protected] on 17 Dec 2013 at 12:20

  • Changed state: WontFix

from androidsvg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.