このxmlファイルをサーバーからのパスであるアンドロイドスタジオの画像として表示するには、 xmlで表示する必要があります。それは可能です。私はこのようにしようとしたが、それはサーバーから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()));
}
おかげ&よろしくファイルとして
サーバから来るベクトルファイル – manu