Android TextView setcompounddrawables 图片不显示的问题
2017-05-31 21:12
627 查看
在代码中可以设置Drawable显示在text的左、上、右、下位置,有如下两个方法:
1、setCompoundDrawables(left, top, right, bottom)
drawable的宽高是按drawable.setBound()设置的宽高,
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use {@code null} if you do not want a Drawable there. The Drawables must already have had {@link Drawable#setBounds} called.
使用之前必须使用Drawable.setBounds设置Drawable的长宽。
2、setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom)
drawable的宽高是按drawable固定的宽高,
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use {@code null} if you do not want a Drawable there. The Drawables’ bounds will be set to their intrinsic bounds.
即通过getIntrinsicWidth()与getIntrinsicHeight()获得,
直接使用setCompoundDrawablesWithIntrinsicBounds代替setCompoundDrawables 在Java代码中使用就可以正常显示。
setCompoundDrawables(left, top, right, bottom) setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom)
1、setCompoundDrawables(left, top, right, bottom)
drawable的宽高是按drawable.setBound()设置的宽高,
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use {@code null} if you do not want a Drawable there. The Drawables must already have had {@link Drawable#setBounds} called.
使用之前必须使用Drawable.setBounds设置Drawable的长宽。
2、setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom)
drawable的宽高是按drawable固定的宽高,
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use {@code null} if you do not want a Drawable there. The Drawables’ bounds will be set to their intrinsic bounds.
即通过getIntrinsicWidth()与getIntrinsicHeight()获得,
直接使用setCompoundDrawablesWithIntrinsicBounds代替setCompoundDrawables 在Java代码中使用就可以正常显示。
相关文章推荐
- android TextView如何通过setCompoundDrawables调整文字和图片的位置(文字显示在图片内)?
- textview.setCompoundDrawables不显示图片
- TextView的setCompoundDrawables不显示问题解决
- TextView的setCompoundDrawables不显示问题解决
- android setCompoundDrawables 不显示问题
- textView.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0)方法无法获取设置系统应用图标的问题
- android TextView setSingleLinexia显示问题
- android setCompoundDrawables 不显示问题
- Android setcompounddrawables 无效,图片不显示
- TextView setCompoundDrawables不显示
- Android开发技巧——TextView加载HTML的图片及代码显示问题
- Android开发技巧——TextView加载HTML的图片及代码显示问题
- Android textview字体颜色显示和图片显示
- Android的TextView/EditText使用CharacterStyle&SpannableString来处理图片显示、字体样式、超链接等
- android的TextView使用Html(图片显示)格式。。。。。。
- Android的TextView使用Html来处理图片显示、字体样式、超链接等
- Android的TextView使用Html来处理图片显示、字体样式、超链接等
- android TextView和EditText中显示图片
- Android控件TextView显示html文件中的图片
- android中textview显示汉字,字母,数字乱行行问题解决