SVG Android
-
Hello all, 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)
My codes are as follows:
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; }
}
Please advice. Thank you.