安卓设置文本与图片相对位置
2016-08-28 17:39
309 查看
手工设置文本与图片相对位置时,常用到如下方法:
setCompoundDrawables(left, top, right, bottom)
分别对应:drawableLeft,drawableTop,drawableRight,drawableBottom。
setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom)
意思是设置Drawable显示在text的左、上、右、下位置。
但是两者有些区别:
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()获得,
setCompoundDrawables(left, top, right, bottom)
Drawable drawable1= getResources().getDrawable(R.drawable.button); drawble1.setBounds( 0, 0, drawable1.getMinimumWidth(),drawable1.getMinimumHeight()); btn1.setCompoundDrawables(null, null, drawable1, null);
分别对应:drawableLeft,drawableTop,drawableRight,drawableBottom。
setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom)
意思是设置Drawable显示在text的左、上、右、下位置。
但是两者有些区别:
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 setCompoundDrawablesWithIntrinsicBounds手工设置文本与图片相对位置说明
- Android setCompoundDrawablesWithIntrinsicBounds手工设置文本与图片相对位置说明
- Android设置图片和文本相对位置
- Android setCompoundDrawablesWithIntrinsicBounds手工设置文本与图片相对位置说明
- UIEdgeInsetsMake设置UIButton的图片、文字的相对位置
- TextField 设置图片的文本位置
- NSMutableAttributedString设置图片与文本的垂直位置
- ios Button 设置图片和文本的位置
- [置顶] 关于图片与文字在一行显示时,文本的垂直方向位置的设置
- 设置RadioButton控件中文本的位置.
- C#:TextBox换行、设置光标位置、随文本滚动
- Silverlight图片相对路径的设置
- 用Word2007批量设置图片位置
- C#word(2007)操作类--新建文档、添加页眉页脚、设置格式、添加文本和超链接、添加图片、表格处理、文档格式转化
- C#:TextBox换行、设置光标位置、随文本滚动
- ASP.NET用户控件中的图片路径如何设置,img相对路径设置方法
- WPF 图片相对路径设置问题
- 关于Silverlight资源文件(如:图片)的放置位置及其引用(相对路径)
- 用Word2007批量设置图片位置
- IEPNGFix 2: 新增支持设置背景位置和图片重复