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

时间:2021-11-16 00:32:25

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.

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

1 个解决方案

#1


33  

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存储库中搜索或在线搜索图像及其名称

#1


33  

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存储库中搜索或在线搜索图像及其名称