`
caryt
  • 浏览: 8564 次
文章分类
社区版块
存档分类
最新评论

android Button,textView 等控件设置控件内嵌周围图片使用方法

 
阅读更多

android Button,textView 等控件设置控件内嵌周围图片使用方法

....................................................................................................................................................................................................................................

1:在布局中直接设置:

android:drawableLeft|Right|Top|Bottom

android:drawablePadding="10dp"//图片与控件文字内容距离设置

2:在代码中动态设置:Drawable img_right,img_left,img_top,img_bottom;

a:获取drawable:img_right=getResources().getDrawable(R.drawable.img_right);......

b:设置图片(必须设置,不设置,图片不显示哦!):

img_right.setBounds(0, 0, img_right.getMinimumWidth(), img_right.getMinimumHeight());

c:button.setCompoundDrawables(null,null,img_right,null);

.................................................................................................................................................................................................................................................



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics