2016-11-07 38 views
-3

在我的應用我使用com.android.support:design:25.0.0獲得FloatingActionButton但是當過我吧無法解析繪製fab_icon的Android

app:fab_icon="@drawable/ic_done" 

設置圖標,我得到一個錯誤

Cannot Resolve symbol @drawable/ic_done

我嘗試過其他圖標,但沒有一個在工作?

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" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab_cust" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end|bottom" 
     android:layout_margin="16dp" 
     /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab_nxt" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end|bottom" 
     android:layout_margin="16dp" 
     app:fab_icon="@drawable/ic_done" 
     /> 

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

搖籃依賴條件:

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile 'com.android.support:support-v4:24.2.1' 
    compile 'com.android.support:design:24.2.1' 
    compile 'com.getbase:floatingactionbutton:1.10.1' 
    testCompile 'junit:junit:4.12' 
} 

編輯:

香港專業教育學院還試圖與Android替代fab_icon:src,卻沒有它的工作。 enter image description here

+0

你可以發佈你的XML代碼 – sasikumar

+0

變化'com.android.support:設計:25.0.0'到'com.android.support:設計:24.2.1'和嘗試 –

+0

@sasikumar我已經更新XML的問題。實際上它不能用特定的名字繪製。如果我沒有錯,它們由設計支持庫提供。但無法訪問它們。 –

回答

0

嘗試添加src而不是圖標。遵循代碼。

android:src="@android:drawable/ic_done"