How to adjust the position of dialog box at a specific position relative to the device in android -


i have android application in there dialog box opens result of button click.in this,i want set position of dialog box below button.when used verticalmargin,the position changes relative device when tested in more 1 devices different screen resolution.what need dialog box should appear below button irrespective of screen size.

after searching in various post have found solution.

the code posted below:

private charsequence[] items = {"set ringtone", "set alarm"};     alertdialog.builder builder = new alertdialog.builder(this);     builder.setitems(items, new dialoginterface.onclicklistener() {         public void onclick(dialoginterface dialog, int item) {              if(item == 0) {              } else if(item == 1) {              } else if(item == 2) {              }         }     });       alertdialog dialog = builder.create();      dialog.requestwindowfeature(window.feature_no_title);      windowmanager.layoutparams wmlp = dialog.getwindow().getattributes();   wmlp.gravity = gravity.top | gravity.left;  wmlp.x = 100;   //x position  wmlp.y = 100;   //y position    dialog.show(); 

here x position's value pixels left right. y position value bottom top.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -