android - Change the dimension of a custom dialog when orientation changes -
how change dimension of dialog in android when orientation changes.
code in oncreate
static final float[] dimensions_diff_landscape = {20, 60}; static final float[] dimensions_diff_portrait = {40, 60}; final float scale = getcontext().getresources().getdisplaymetrics().density; int orientation = getcontext().getresources().getconfiguration().orientation; float[] dimensions = (orientation == configuration.orientation_landscape) ? dimensions_diff_landscape : dimensions_diff_portrait; addcontentview(mcontent, new linearlayout.layoutparams( display.getwidth() - ((int) (dimensions[0] * scale + 0.5f)), display.getheight() - ((int) (dimensions[1] * scale + 0.5f)))); i want same when orientation change. please help
just check out custom code set dialog height according oriebtation : works me implementing dialog become flexible ...i m using in tablet ..
windowmanager winman = (windowmanager) context.getsystemservice(context.window_service); int height = winman.getdefaultdisplay().getheight(); int width=winman.getdefaultdisplay().getwidth(); if(height>width){ if(devicetype.getdevicetype(context)==device.nexus7){ dialoglayout.setlayoutparams(new framelayout.layoutparams(700,1100)); }else if (devicetype.getdevicetype(context)==device.galaxytab2){ dialoglayout.setlayoutparams(new framelayout.layoutparams(580,900)); }else if(devicetype.getdevicetype(context)==device.galaxy10){ dialoglayout.setlayoutparams(new framelayout.layoutparams(700,1100)); } else{ if(devicetype.getdevicetype(context)==device.nexus7){ dialoglayout.setlayoutparams(new framelayout.layoutparams(700,700)); }else if (devicetype.getdevicetype(context)==device.galaxytab2){ dialoglayout.setlayoutparams(new framelayout.layoutparams(700,500)); system.out.println("galaxy tab 2 landescape"); }else if(devicetype.getdevicetype(context)==device.galaxy10){ dialoglayout.setlayoutparams(new framelayout.layoutparams(700,700)); }
Comments
Post a Comment