Android 动态设置TextView的drawableLeft

有两种:

setCompoundDrawables 画的drawable的宽高是按drawable.setBound()设置的宽高,
所以才有The Drawables must already have had setBounds(Rect) called,即使用之前必须使用Drawable.setBounds设置Drawable的长宽。

  而setCompoundDrawablesWithIntrinsicBounds是画的drawable的宽高是按drawable固定的宽高,
所以才有The Drawables' bounds will be set to their intrinsic bounds.即通过getIntrinsicWidth()与getIntrinsicHeight()获得。

 

示例:

Android 动态设置TextView的drawableLeft_第1张图片

你可能感兴趣的:(Android 动态设置TextView的drawableLeft)