Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale in ImageView #40

Open
GoogleCodeExporter opened this issue Jul 24, 2015 · 7 comments
Open

Scale in ImageView #40

GoogleCodeExporter opened this issue Jul 24, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

SVGImageView doesn't properly scale the image. Even if w o h are changed, it 
seems that only takes w and preserves aspect ratio


SVGImageView siv = new SVGImageView(this);
siv.setImageResource(R.drawable.image_svg);

int w=100;
int h=100;

RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(w,h);
siv.setLayoutParams(rllp);


Original issue reported on code.google.com by thaedne...@gmail.com on 7 Jul 2014 at 10:06

Attachments:

@GoogleCodeExporter
Copy link
Author

So do you mean it does enlarge, but you want it to stretch to exactly fit both 
width and height?

Keeping the aspect ratio is the default behaviour.  If you want it to do the 
stretch, try adding the following to your code:

siv.setScaleType(ScaleType.FIT_XY);

I think it should do what you want.


Original comment by paul.leb...@gmail.com on 7 Jul 2014 at 10:28

@GoogleCodeExporter
Copy link
Author

For some reason, the image doesn stretch to the parameters I give it. I'd like 
the image stretch like the attachment.

Thanks

Original comment by thaedne...@gmail.com on 8 Jul 2014 at 2:51

Attachments:

@GoogleCodeExporter
Copy link
Author

Hi thaenevol

Did you try my suggestion?  What happened?

Original comment by paul.leb...@gmail.com on 8 Jul 2014 at 9:06

@GoogleCodeExporter
Copy link
Author

Hi. Yes. I've attached two files, one with fitxy and the other with center. It 
'cuts' the image...

Original comment by thaedne...@gmail.com on 8 Jul 2014 at 8:41

Attachments:

@GoogleCodeExporter
Copy link
Author

Hi. Based on this: https://code.google.com/p/svg-android/issues/detail?id=7 I 
tried with:

public class CustomPictureDrawable extends PictureDrawable {

    private float scalex, scaley;

    public CustomPictureDrawable(Picture picture, float scalex, float scaley) {
        super(picture);
        this.scalex = scalex;
        this.scaley = scaley;
    }

    @Override
    public void draw(Canvas canvas) {
        Matrix original = canvas.getMatrix();
        canvas.scale(scalex, scaley);
        super.draw(canvas);
        canvas.setMatrix(original);
    }
}

In SVGImageView.java

But the image is still in the center.


Original comment by thaedne...@gmail.com on 9 Jul 2014 at 4:01

@GoogleCodeExporter
Copy link
Author

I see the same behaviour using this XML definition:

    <com.caverock.androidsvg.SVGImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:contentDescription="@string/content_desc_overlay"
        android:scaleType="fitXY"
        svgimageview:svg="@raw/thirds" />

Original comment by o...@itmaze.com.au on 3 Oct 2014 at 2:55

@GoogleCodeExporter
Copy link
Author

anyone find solution for this ? thx

Original comment by fadimoa...@gmail.com on 11 Apr 2015 at 12:20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant