Using an SVG as a background drawable in Android

后端 未结 2 400
清酒与你
清酒与你 2021-02-04 06:40

I\'m trying to use an SVG image (created using Inkscape and saved as plain SVG) as a background for my application. I\'m trying to do this using the svg-android lib

2条回答
  •  你的背包
    2021-02-04 07:07

    I tried an example using the following code and it is shows the background correctly:

    LinearLayout root = (LinearLayout) findViewById(R.id.background);
    SVG svg = SVGParser.getSVGFromResource(getResources(),
                    R.raw.android_body);
    Drawable pictureDrawable = svg.createPictureDrawable();
    root.setBackgroundDrawable(pictureDrawable);
    

    Have you tried with another svg?

提交回复
热议问题