SVG Android Exception [英] SVG Android Exception

查看:132
本文介绍了SVG Android Exception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了处理SVG-android库的问题。在我的主要活动中,我想在imageview上显示SVG对象,但是,我正面临这个错误。

I have met problems dealing with the SVG-android library. In my main activity I want to display the SVG object on the imageview however, i am facing this error.

java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.androidsvgdemo/com.example.androidsvgdemo.MainActivity}:
com.larvalabs.svgandroid.SVGParseException: 
org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: not well-formed (invalid token)

我的代码如下:

package com.example.androidsvgdemo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

import com.larvalabs.svgandroid.SVG;
import com.larvalabs.svgandroid.SVGParser;

import android.os.Bundle;
import android.widget.ImageView;
import android.app.Activity;

public class MainActivity extends Activity {

    ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imageView = (ImageView)findViewById(R.id.img1);
        //Parse the SVG file from the resource
        SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.imageandroid);
        //Get a drawable from the parsed SVG and apply to ImageView
        imageView.setImageDrawable(svg.createPictureDrawable());

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

请咨询。谢谢。

推荐答案

错误表明SVG文件格式错误......你需要用<编辑它来编辑它a href =http://www.inkscape.org/ =nofollow> Inkskape 并再次保存。这应该重新您的SVG文件。

The error indicates that the SVG file is malformed XML... You'll need to edit it with Inkskape and save it again. This should repare your SVG file.

这篇关于SVG Android Exception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆