如何使用Android的内置图标

use*_*158 6 android android-drawable

我想用Android的内置图标,我不知道怎么样,我试着用这两行:

    android:background="@drawable/ic_lock_silent_mode_off"

    android:background="R.drawable.ic_lock_silent_mode_off"
Run Code Online (Sandbox Code Playgroud)

这两行都不适用于我,如何将此图标用于我的按钮?

我收到此错误:

error: Error: No resource found that matches the given name (at 'background' with value '@drawable/ic_lock_silent_mode_off').
Run Code Online (Sandbox Code Playgroud)

mat*_*ash 12

有了它,你试图引用自己的drawable,而不是Android的.

你需要使用:

android:background="@android:drawable/ic_lock_silent_mode_off"
Run Code Online (Sandbox Code Playgroud)

  • 供参考,这里是[Google的图标文档](http://developer.android.com/design/style/iconography.html#menuapx)和[下载链接](http://developer.android.com/design/ downloads/index.html)获取标准主题图标 (2认同)