0

SVG-android ライブラリの処理で問題が発生しました。私の主な活動では、イメージビューに SVG オブジェクトを表示したいのですが、このエラーに直面しています。

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;
    }

}

ご意見をお聞かせください。ありがとうございました。

4

1 に答える 1

0

このエラーは、SVG ファイルが不正な XML であることを示しています... Inkskapeで編集して、再度保存する必要があります。これにより、SVG ファイルが修復されます。

于 2013-12-31T08:56:56.627 に答える