When we show an AlertDialog in android it shows in the center of the screen. Is there any way to change the position?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
To make the setting come info effect, I added the following code
dialog.getWindow().setAttributes(wmlp);
after change the value of wmlp in gypsicoder‘s answer, or the setting of wmlp doesn't take into effect by my test.
If you for example want to move the progressdialog a bit further down, and not set the exakt pixel position, then this is sufficient:
After searching in various post I have found the solution.
The code is posted below:
Here x position's value is pixels from left to right. For y position value is from bottom to top.
These answers will move the position of the AlertDialog, however, the position of the displayed dialog will also include the padding around the dialog.
If you want to get rid of this padding (for example, to place your dialog flush against the bottom of the screen), you will also need to override the default AlertDialog style in your styles.xml to set the windowBackground to null, like so:
As well as setting the Window.LayoutParameters as described in the accepted answer.
Special shout-out to @David Caunt whose answer at: remove border, padding from Dialog completed this picture.