开发者

dynamic imagebutton wrap_content doesn't 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜