簡體   English   中英

我們如何從服務器獲取xml矢量圖像文件並在android studio的imageview中查看

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM