-1
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/content"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="8dp">
<LinearLayout
android:orientation="horizontal"
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:gravity="center_horizontal">
<XamSvg.SvgImageView
android:id="@+id/icon"
local:svg="res:images.0Password"
android:layout_width="fill_parent"
android:layout_height="40dp" />
</LinearLayout>
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/drawableAutoSize"
android:scaleType="fitCenter"
android:background="#AAD39F" />
</LinearLayout>
I Svg Bild zeigen will, gespeichert ist, die in meinem App-Verzeichnis gespeichert ist, schreibe ich einen Code, der in ziehbar Ordnern gespeicherten Bild zeigt, aber ich mag Bild zeigen, aus mein App-Verzeichnis als auch das Bild in "Android/data/QR.Android/files/Q317664.svg"Wie SVG-Bild zeigen, dass in meinem App-Verzeichnis
using System;
using System.Linq;
using System.Reflection;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using XamSvg;
using Android.Graphics;
namespace QR.Android
{
[Activity(Label = "Activity3",Theme = "@android:style/Theme.Holo.Light.NoActionBar.Fullscreen")]
public class Activity3 : Activity
{
int[] rawIds;
int[] drawableViewIds;
private string[] sharedNames;
int currentId;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.layout1);
//Initialize the cross platform color helper
Setup.InitSvgLib();
//Tells XamSvg in which assembly to search for svg when "res:" is used
var assembly = typeof(AppDomain).GetTypeInfo().Assembly;
XamSvg.Shared.Config.ResourceAssembly = assembly;
//Get all svg resource ids in the raw folder
rawIds = typeof(Resource.Drawable)
.GetFields()
.Where(f => f.IsLiteral)
.Select(f => (int)f.GetRawConstantValue())
.ToArray();
//Get all drawing zones in the current layout
drawableViewIds = typeof(Resource.Id)
.GetFields()
.Where(f => f.IsLiteral && f.Name.StartsWith("drawable"))
.Select(f => (int)f.GetRawConstantValue())
.ToArray();
//Get all svg resources in the shared assembly
sharedNames = assembly.GetManifestResourceNames().Where(n => n.EndsWith(".svg")).OrderBy(n => n).ToArray();
//When clicked, change the svg source in all zones
var contentView = FindViewById(Resource.Id.content);
currentId = currentId + 2;
contentView.Click += (sender, e) =>
{
if (currentId < rawIds.Length)
LoadImageTest(rawIds[currentId]);
// else
// LoadImageTest(sharedNames[currentId-rawIds.Length]);
// currentId = (++currentId)%(rawIds.Length+sharedNames.Length);
};
LoadImageTest(rawIds[currentId++]);
}
void LoadImageTest(int rawId)
{
foreach (var drawableId in drawableViewIds)
{
// if (drawableID != Resource.Id.drawable100)
// continue;
var v = FindViewById<ImageView>(drawableId);
var drawable = SvgFactory.GetDrawable(Resources, rawId);
v.SetImageDrawable(drawable);
}
}
}
}
wie kann ich dieses plugin benutzen bitte gib mir ein beispiel. –
https://github.com/paulpatarinski/Xamarin.Forms.Plugins/tree/master/SVG gibt es ein Beispiel im Repository dieses Plugins –