I want to add OnclickListener for a button,where in I want to display the Dialog box on the left of the screen on click of it.I tried to implement that but it always appears on the center of the screen.Any idea on how to implement that?
相关问题
- 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
Just add following line in your java file and extra space will remove from dialog box.
Above code work for me. I hope it will be work for others too. Note: You need to pass activity context instead of normal context (getApplicationContext()).
If I understand your question correctly - you want to align your dialog not appear on the center of the screen. Then look at this code sample.
Here x position's value is pixels from left to right. For y position value is from bottom to top.
Before calling
#show()
on yourAlertDialog
you can adjust the gravity of the dialog window:This would shift the dialog to the left of the screen. Adjust your gravity flags according to your taste.