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?
精彩评论