imageview - How to create views that will run on multiple screen in Android? -
i developing android application. creating views programmatically, , necessary application should dynamic. can put resources per hdpi, mdpi , ldpi want know how set width , height of view proper on android screens. using density factor follows.
imageview imgmainpic = new imageview(this); relativelayout.layoutparams rllpimg = new relativelayout.layoutparams(relativelayout.layoutparams.fill_parent, (int)(440*global.ndensity)); rllpimg.addrule(relativelayout.align_top,mainrelativelyt.getid()); imgmainpic.setid(1); imgmainpic.setlayoutparams(rllpimg); imgmainpic.setbackgroundresource(r.drawable.pic1); mainrelativelyt.addview(imgmainpic);
it not practice calculate width , heights of views based on device. best way define different layouts different screens using small, large, xlarge etc.. here link android developer supporting multiple screen sizes..
Comments
Post a Comment