2016-04-16 3 views
1

私のアンドロイドプロジェクトでSVGファイルを使用するには、vector compatを使用する必要があります。 VectorDrawableCompatの使用

は、最初に私はその後、私は公式ブログを踏襲 http://a-student.github.io/SvgToVectorDrawableConverter.Web/

に記載のベクターに私のSVGファイルを変換http://android-developers.blogspot.fr/2016/02/android-support-library-232.html

だからここに私のbuild.gradle

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "xxx" 
     minSdkVersion 16 
     targetSdkVersion 22 
     versionCode 22 
     versionName "2.0" 
     vectorDrawables.useSupportLibrary = true 
    } 
    [...] 
} 

で、私のxml Iでこれを使用する

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:card="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/dark_grey" 
    tools:ignore="MissingPrefix"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="@dimen/login_margin"> 

     <ImageView 
      android:id="@+id/info_about_app" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:background="@drawable/back_login" 
      app:srcCompat="@drawable/vector"/> <-- Important line 

と私のベクトルが

<?xml version="1.0" encoding="utf-8"?> 
<vector xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:auto="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:width="425dp" 
     android:height="252dp" 
     android:viewportHeight="504" 
     android:viewportWidth="850" 
     auto:height="252dp" 
     auto:viewportHeight="504" 
     auto:viewportWidth="850" 
     auto:width="425dp" 
     tools:ignore="NewApi"> 
    <group 
     android:translateY="-548.3622" 
     auto:translateY="-548.3622"> 

のようにAndroidのメーカーのプレビューに問題が見えませんが、私は私のアプリを実行しようとすると、私は次のエラー

Error:(2) No resource identifier found for attribute 'viewportHeight' in package 'xxx' 

を取得し、私はこのエラーが悪いが原因だと思いますidsバックポートですが、その役割は

vectorDrawables.useSupportLibrary = true 

android plugin for gradle ==> 2.1.0-beta1 

どのように修正できますか?

+0

バックポートには 'auto:'が、APIには 'android:'が使用されています。私はsurではありません。どちらか一方を削除する必要があります – mrroboaat

+1

あなたは絶対に正しいです。 'auto:'を削除する必要があります。そうしないと、この種のエラーが発生します(バックポートは動作します)。 – mrroboaat

答えて

1

ただ、この行を削除します。

auto:viewportHeight="504" 

これはNo resource identifier found for attribute 'viewportHeight'が私を示唆するものです。

またはサポートベクター互換ライブラリをインポートしていないこと。
しかし、私はあなたがそうしたと思う傾向があります。

関連する問題