开发者

dynamic imagebutton wrap_content doesn't wrap_content

开发者 https://www.devze.com 2023-03-22 19:41 出处:网络
I\'ve created an android imagebutton with code and add an image source to it. The layoutparams of the imagebutton are wrap_content

I've created an android imagebutton with code and add an image source to it. The layoutparams of the imagebutton are wrap_content

`LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
public ImageButton createActionBarItem(int id, int img, String tag){
ImageButton btnImage = new ImageButton(context);
btnImage.setLayoutParams(layoutParams);
btnImage.setImageResource(img);
btnImage.setId(id);
btnImage.setTag(tag);
return btnImage;
}`

The problem I experience is that the imagebackground (even the default background) is smaller than the imageResource Any idea to make the imageButtonBackgroun开发者_开发问答d stretch so that the drawable fits in?

0

精彩评论

暂无评论...
验证码 换一张
取 消