EditText有两种设置图标的方法:
1、setCompoundDrawables(left, top, right, bottom)
这个方法,必须设置宽高使,用之前必须使用Drawable.setBounds设置Drawable的长宽。
2、setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom)
这个方法,是照drawable的宽高画的图片。
所以在代码里面,使用setCompoundDrawablesWithIntrinsicBounds就会显示出来图片。
本文介绍了在Android开发中,EditText组件设置图标的两种方法:使用setCompoundDrawables方法需手动设置Drawable尺寸;而setCompoundDrawablesWithIntrinsicBounds方法则依据Drawable自身的尺寸进行绘制,更加便捷。
3409

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



