[英]how can we get the xml vector image file from server & view it in the imageview in android studio
如何更改此xml文件以在android studio中查看為圖像,該路徑來自服務器,不應更改為png,而應使用xml查看。 請幫我
我這樣嘗試過,但是沒有用
字符串uri =“ https://s3-ap-southeast-1.amazonaws.com/android.image/success.xml ”;
VectorDrawable d = new VectorDrawable();
try(InputStream in = new FileInputStream(uri))
{
XmlPullParser p = Xml.newPullParser();
p.setInput( in, null );
d.inflate( c.getResources(), p, Xml.asAttributeSet(p) ); // FAILS
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
int imageResource = c.getResources().getIdentifier(uri, null, c.getPackageName());
Drawable res;
if(imageResource!=0){
res = c.getResources().getDrawable(imageResource);
}
else{
res = c.getResources().getDrawable(c.getResources().getIdentifier(uri, null, c.getPackageName()));
}
感謝和問候
從服務器下載時,將此xml視為文件。 嗯,我對此不確定。 但是你可以試試看
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.