android - Fixed Size Screen Element -


i attempted make simple app see if make element fixed size, in case 4cm wide, regardless of device. tried use screen xdpi, use inch, multiply constant 4cm. doesn't appear working after trying on few different devices.

    final windowmanager w = (windowmanager) getapplicationcontext().getsystemservice(context.window_service);     final display d = w.getdefaultdisplay();     final displaymetrics m = new displaymetrics();     d.getmetrics(m);      //find correct x density , multiply 1.5748 4cm     float density = m.xdpi;     density = (float) (density * 1.5748);     int intdensity = (int)math.ceil(density);      //now set view dimensions want, must inside of it's own layout?     box.setlayoutparams(new linearlayout.layoutparams(intdensity,100)); 

any suggestions?


Comments

Popular posts from this blog

android - Automated my builds -

how to proxy from https to http with lighttpd -

python - Flask migration error -