在图像视图android中从android.R.drawable设置图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3683179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 11:20:15  来源:igfitidea点击:

Set image from android.R.drawable in image view android

androidimageview

提问by user430926

i know how to set image/icon from our res/drawable

我知道如何从我们的 res/drawable 中设置图像/图标

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

If we set it directly from the code: imageView1.setImageResource(R.drawable.android_green_3d);

如果我们直接从代码中设置: imageView1.setImageResource(R.drawable.android_green_3d);

But we can also get the icon from android.R.drawable like this: imageView1.setImageResource(android.R.drawable.ic_menu_more);

但是我们也可以像这样从 android.R.drawable 获取图标: imageView1.setImageResource(android.R.drawable.ic_menu_more);

How to set image/icon in xml id the source is android.R.drawable? Anyone know? Thanks in advance.

如何在源是android.R.drawable的xml id中设置图像/图标?有人知道吗?提前致谢。

回答by WarrenFaith

Thats easy: change @drawable/to @android:drawable/. Code completion didn't work in this case, so you should search in the GIT repository or online for the images and their names

很简单:更改@drawable/@android:drawable/. 代码完成在这种情况下不起作用,因此您应该在 GIT 存储库或在线搜索图像及其名称