I made a simple AlertDialog
in my Activity:
View view = layoutInflater.inflate(R.layout.my_dialog, null);
AlertDialog infoDialog = new AlertDialog.Builder(MyActivity.this)
.setView(view)
.create();
infoDialog.show();
With above code, the dialog shows at the (about) the center of the screen.
I am wondering, how can I customize the dialog position to make it showing just under the top Action Bar ? (Is there anyway to change the gravity or something of the dialog?) and how to do it based on my code??
I found this code snippet from @gypsicoder code here
Here x position's value is pixels from left to right. For y position value is from bottom to top.
For me, this worked out pretty well where I was trying to position my dialog somewhere exactly at the bottom of the textview where it gets selected.
I used this code to show the dialog at the bottom of the screen:
This code also prevents android from dimming the background of the dialog, if you need it. You should be able to change the gravity parameter to move the dialog about
you can customize you dialog based on gravity and layout parameters change gravity and layout parameter on the basis of your requirenment
just add this to your code: