android - 如何在 Android 中使用系统提供的图标(例如 expander_ic_maximized)

标签 android

你能告诉我如何使用 android 的图标 expander_ic_maximized 吗? 我发现在 frameworks/base/core/res/res/drawable-hdpi/expanderic_minimized.9.png

这是我的布局 xml 文件:

<ImageView android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/expander_ic_minimized">

但是我得到这个错误:

res/layout/test.xml:70: error: Error: Resource is not public. (at 'src' with value '@android:drawable/expander_ic_maximized').

最佳答案

您可以在您的android SDK 安装目录中找到所有android 图标。 F.ex. /opt/android-sdk-linux/platforms/android-16/data/res/drawable-hdpi/ 在我的电脑上。不同的安卓版本和不同的屏幕分辨率有不同的图标集。将 expander_ic_minimized.png 文件复制到您的项目 drawable 文件夹中,图标将可用。

根据安卓开发者guide :

Because these resources can change between platform versions, you should not reference these icons using the Android platform resource IDs (i.e. menu icons under android.R.drawable). If you want to use any icons or other internal drawable resources, you should store a local copy of those icons or drawables in your application resources, then reference the local copy from your application code. In that way, you can maintain control over the appearance of your icons, even if the system's copy changes.

关于android - 如何在 Android 中使用系统提供的图标(例如 expander_ic_maximized),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3239486/

相关文章:

android - Android应用程序可以修改设备的音频系统吗?

java - 从 SQL 数据库中删除条目后出现空指针异常

适用于手机和电视的 Android 通用应用程序 (Lollipop)

java - 让 XmlPullParser 忽略空格?

android - CardView 和 RecyclerView 分隔符行为

java - 在Gradle中定义任务之前添加对任务的依赖关系

android - 我应该在开发过程中将调试 keystore 与 Google Play 游戏服务一起使用吗?

android - 如何以编程方式使android软键盘静音?

java - Android:在 OnClickListener 中获取 View 的文本

android - oauth2 : Logoff currently logged in google user and then send the oauth url from my app