###前提・実現したいこと
xamarin.Android でFragmentの背景にグラディエーションの入ったSVGファイルの画像を設定しようとしています
Android Studio でsvgファイルをxml化して(ベクターアセット)、表示確認した後xamarin.androidの方に組み込んだのですが、「inflater.Inflat....」のところで例外エラーになってしまいました。
レイアウトでグラディエーション部分を外すと例外にはなりません
xamarin.androidで何か設定等抜けているのでしょうか
xmlの編集の仕方を変更するなど含め、表示の仕方をご存じの方がいましたらご教授ください
###発生している問題
例外(Unhandled Exception)になる
Android.Views.InflateException: Binary XML file line #1: Error inflating class <unknown>
###該当のソースコード
<例外になった箇所>
以下の「inflater.Inflate~」呼び出し時」
lang
1public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 2{ 3 View view = base.OnCreateView(inflater, container, savedInstanceState); 4 var rootView = inflater.Inflate(Resource.Layout.layoutPS, container, false); 5 return rootView; 6}
<背景に設定しようとしたxml>
XML
1<vector xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:aapt="http://schemas.android.com/aapt" 3 android:width="720dp" 4 android:height="260dp" 5 android:viewportWidth="720" 6 android:viewportHeight="260"> 7 <path 8 android:pathData="M0,0h720v260h-720z"> 9 <aapt:attr name="android:fillColor"> 10 <gradient 11 android:startY="260" 12 android:startX="360.0005" 13 android:endY="4.882813E-4" 14 android:endX="360.0005" 15 android:type="linear"> 16 <item android:offset="0" android:color="#FF000000"/> 17 <item android:offset="0.04" android:color="#FF373A3C"/> 18 </gradient> 19 </aapt:attr> 20 </path> 21 <path 22 android:pathData="M20,215h680v33h-680z"> 23 <aapt:attr name="android:fillColor"> 24 <gradient 25 android:startY="248" 26 android:startX="360.0005" 27 android:endY="215" 28 android:endX="360.0005" 29 android:type="linear"> 30 <item android:offset="0" android:color="#FF333333"/> 31 <item android:offset="0.04" android:color="#FF000000"/> 32 </gradient> 33 </aapt:attr> 34 </path> 35 <path 36 android:pathData="M333,97h367v3h-367z" 37 android:fillColor="#FFFFFF"/> 38 <path 39 android:pathData="M300,96.667c0,5.154 -4.179,9.333 -9.333,9.333H29.333C24.179,106 20,101.821 20,96.667V22.333C20,17.179 24.179,13 29.333,13h261.333c5.155,0 9.333,4.179 9.333,9.333V96.667z" 40 android:strokeWidth="2" 41 android:fillColor="#00000000" 42 android:strokeColor="#FFFFFF"/> 43 <path 44 android:pathData="M420,198.666c0,5.155 -4.179,9.334 -9.334,9.334H29.333c-5.155,0 -9.333,-4.179 -9.333,-9.334v-74.333c0,-5.155 4.179,-9.333 9.333,-9.333h381.333c5.155,0 9.334,4.179 9.334,9.333V198.666z" 45 android:strokeWidth="2" 46 android:fillColor="#00000000" 47 android:strokeColor="#FFFFFF"/> 48 <path 49 android:pathData="M700,198.666c0,5.155 -4.179,9.334 -9.333,9.334H469.333c-5.154,0 -9.333,-4.179 -9.333,-9.334v-74.333c0,-5.155 4.179,-9.333 9.333,-9.333h221.334c5.154,0 9.333,4.179 9.333,9.333V198.666z" 50 android:strokeWidth="2" 51 android:fillColor="#00000000" 52 android:strokeColor="#FFFFFF"/> 53</vector> 54``` 55###試したこと 56・Android studioで表示実行 正常 57・xamarin.Androidで表示実行 例外エラー 58・gradient を含むPathを削除して表示 正常(当然グラディエーションなし) 59・「android:endY="4.882813E-4"」を「android:endY="0.0004"」に変更 例外エラー 60 61### 補足情報 62xamarin.Android、C# 使用 63ターゲットはAndroid 5.1 使用
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。