Drawable boundImage;
Resources res = getResources();
boundImage = res.getDrawable(R.drawable.yourimage);
//调用setCompoundDrawables时,必须调用Drawable.setBounds()方法,否则图片不显示
boundImage.setBounds(0, 0, boundImage.getMinimumWidth(), boundImage.getMinimumHeight());
yourview.setCompoundDrawables(boundImage, null, null, null); //设置左图标
转载于:https://my.oschina.net/u/1028833/blog/269136
本文介绍了一种在Android应用中正确显示图标的技巧。通过使用getDrawable方法获取资源,并且调用Drawable.setBounds()方法来确保图标正常显示。此外,还介绍了如何使用setCompoundDrawables将图标设置到视图左侧。
1867

被折叠的 条评论
为什么被折叠?



