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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -