簡體   English   中英

在 Android Studio 中導入矢量資源時無法解析符號

[英]Cannot Resolve Symbol when importing vector asset in Android Studio

我正在使用 AS 1.5.1

所以我嘗試通過以下方式導入矢量資產:

http://developer.android.com/tools/help/vector-asset-studio.html

我試圖像這樣使用我的可繪制對象:

android:src="@android:drawable/ic_av_timer_24dp.xml"

但是,它以紅色突出顯示並告訴我無法解析符號。

為什么?

這是我的整個布局文件:

    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="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:fitsSystemWindows="true"
    tools:context="org.isg.shinobi.isg.MainActivity"
    android:id="@+id/coordinator">

    <android.support.design.widget.AppBarLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />



    </android.support.design.widget.AppBarLayout>

    <FrameLayout
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:id="@+id/frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </FrameLayout>


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_av_timer_24dp.xml" />

</android.support.design.widget.CoordinatorLayout>

這是我的可繪制結構。 在此處輸入圖像描述

謝謝!

只需按照以下步驟操作:

  1. app:src="@android:drawable/xyz"更改為app:srcCompat="@drawable/xyz"
  2. 在 build.gradle(Module:app) 中的 defaultConfig下添加這一行 - vectorDrawables.useSupportLibrary = "true"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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