将uri检索到xml / svg并在ImageView中显示

问题描述 投票:-1回答:1

我在Firebase存储中有两个文件:

  • 奖杯color.svg
  • 奖杯color.xml

我的xml是使用svg中的“New vector asset”生成的xml。

我想从存储中获取这些文件中的任何一个并将它们放入ImageView中。我是Uri,从存储,现在我需要在imageview中显示。

obs:myImageView.setImageUri(myUri)不起作用,因为不接受svg或xml vector资产。

<vector android:autoMirrored="true" android:height="62dp"
android:viewportHeight="61.757" android:viewportWidth="63.248"
android:width="63dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#f79733" android:fillType="evenOdd" android:pathData="M31.669,0C45.054,0 55.904,2.873 55.904,6.417s-10.85,6.418 -24.235,6.418S7.434,9.961 7.434,6.417 18.284,0 31.669,0ZM31.669,0.992C43.755,0.992 53.553,3.2 53.553,5.921s-9.8,4.929 -21.884,4.929S9.785,8.643 9.785,5.921 19.583,0.992 31.669,0.992Z"/>
<path android:fillColor="#f08835" android:pathData="M9.785,5.921a21.884,4.929 0,1 0,43.768 0a21.884,4.929 0,1 0,-43.768 0z"/>
<path android:fillColor="#fac02d" android:fillType="evenOdd" android:pathData="M7.457,6.691C8.722,21.721 17.027,46.257 32.478,46.257 47.816,46.257 52.963,22.497 55.793,7.037c-1.178,3.253 -11.528,5.8 -24.122,5.8 -13.038,0 -23.67,-2.726 -24.212,-6.143Z"/>
<path android:fillColor="#ffcc4d" android:fillType="evenOdd" android:pathData="M28.362,43.173a14.2,14.2 0,0 0,2.563 0.236c8.824,0 14.274,-7.863 17.851,-17.485L40.539,27.473C37.719,34.85 33.851,40.931 28.362,43.173ZM50.643,20.219c1.053,-3.646 1.9,-7.369 2.609,-10.88a30.3,30.3 0,0 1,-8.312 2.448c-0.727,3.459 -1.581,6.992 -2.607,10.392Z"/>
<path android:fillColor="#f79733" android:pathData="M8.787,15.353L3.278,15.353c0.13,3.554 0.815,6.543 2.5,8.69 1.411,1.8 3.591,3.07 6.833,3.673 0.494,1.192 1.022,2.362 1.585,3.5 -5.3,-0.512 -8.766,-2.339 -10.978,-5.158 -2.435,-3.105 -3.228,-7.3 -3.211,-12.2Q0,13.792 0,13.723a1.631,1.631 0,0 1,1.631 -1.631L8.155,12.092c0.182,1.067 0.393,2.157 0.632,3.261ZM54.137,15.353L59.97,15.353c-0.13,3.554 -0.815,6.543 -2.5,8.69a10.665,10.665 0,0 1,-6.754 3.658c-0.419,1.186 -0.865,2.349 -1.341,3.48 5.116,-0.554 8.489,-2.363 10.655,-5.125 2.436,-3.105 3.229,-7.3 3.212,-12.2q0.006,-0.068 0.006,-0.137a1.631,1.631 0,0 0,-1.631 -1.631L54.825,12.088c-0.216,1.07 -0.444,2.16 -0.687,3.261Z"/>
<path android:fillColor="#ef8136" android:fillType="evenOdd" android:pathData="M31.669,15.811l2.291,4.593 4.737,0.943 -3.321,3.781 0.636,5.176 -4.344,-2.256L27.323,30.304l0.636,-5.176 -3.321,-3.781 4.737,-0.943Z"/>
<path android:fillColor="#f79733" android:fillType="evenOdd" android:pathData="M37.435,55.045a13.836,13.836 0,0 1,-2.508 -9.008,13.961 13.961,0 0,1 -2.452,0.217 14.206,14.206 0,0 1,-4.518 -0.738,16.47 16.47,0 0,1 -2.293,9.56c-4.4,0.579 -7.424,1.774 -7.424,3.156 0,1.948 6.011,3.527 13.426,3.527s13.426,-1.579 13.426,-3.527c0,-1.406 -3.129,-2.619 -7.657,-3.186Z"/>
<path android:fillColor="#fac02d" android:fillType="evenOdd" android:pathData="M43.334,56.483a1.392,1.392 0,0 1,0.51 0.992c0,1.912 -5.476,3.462 -12.231,3.462 -6.252,0 -11.407,-1.328 -12.141,-3.041 1.92,1.272 6.19,2.157 11.148,2.157 6.755,0 12.231,-1.642 12.231,-3.667a1.075,1.075 0,0 0,-0.006 -0.11Q43.103,56.378 43.334,56.483Z"/>

android xml svg uri
1个回答
1
投票

VectorDrawables需要来自资源。据我所知,没有办法从外部位置加载它们。

但是有Android的SVG渲染库可以让你这样做。包括我的一个:AndroidSVG

© www.soinside.com 2019 - 2024. All rights reserved.