TextView的setCompoundDrawables不显示问题解决

来源:互联网 发布:effective java电子版 编辑:程序博客网 时间:2024/05/01 15:45
TextView可以用过调用setCompoundDrawables设置一张图片出现在上下左右四个地方。代码如下:

  Drawable drawable = getResources().getDrawable(R.drawable.img);
        drawable.setBounds(0, 0, 32, 32);
        textView.setCompoundDrawables(drawable, null, null, null);

  注意到这个Drawables必须已经调用过了setBounds。如果不设置则无法显示。



转自:http://www.amsoft.cn/post-108.html

0 0
原创粉丝点击