0

I need to display a dialog as show in the Link. Can anyone please tell me how I can get the position for different mobile screen size and how I can add the pointer as shown in the image. I don't have any action bar in this activity.

I would like to get exactly as given the image. The pointer should point exactly to the corresponding icon and I would like to do the same for all those three icons given in the top right corner.

Parthiban M
  • 1,104
  • 1
  • 10
  • 30
  • Possible duplicate of [How to change the position of a progress dialog?](http://stackoverflow.com/questions/3392256/how-to-change-the-position-of-a-progress-dialog) – Chris Mar 10 '16 at 10:09
  • Hi, I would like to place the dialog exactly as shown in the image, with the pointer pointing to the corresponding icon. – Parthiban M Mar 10 '16 at 10:19

1 Answers1

0

The code is below:

private CharSequence[] items = {"Android M", "Android N"};
    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 is pixels from left to right. For y position value is from bottom to top.

Bhumit
  • 338
  • 3
  • 12