Covering android ImageView -
while working on project found image couldn't cover whole space of imageview completely! first time have got problem this.
here code :
int imgid = getresources().getidentifier("test1", "drawable", getpackagename()); photo=new linearlayout(this); lp = new linearlayout.layoutparams(width/2,width/2); photo.setlayoutparams(lp); photo.setorientation(linearlayout.vertical); photo.setbackgroundcolor(getresources().getcolor(r.color.maingreen)); img = new imageview(this); lp = new linearlayout.layoutparams(layoutparams.match_parent,layoutparams.match_parent); img.setlayoutparams(lp); img.setbackgroundcolor(getresources().getcolor(r.color.black)); img.setimageresource(imgid); photo.addview(img);
i have used piece of code many times before. image covered imageview's space not working well! problem? how can cover imageview completely?
img.setbackground(imgid); //img.setimageresource(imgid);
or
img.setbackground(imgid); img.setscaletype(imageview.scaletype.fit_xy); img.setimageresource(imgid);
Comments
Post a Comment