英文:
How to make a the dialog choose box like this custom dialog with cancel button on the top right corner like this one?
问题
如何制作类似于此自定义对话框的对话框选择框,在Android Studio 中位于右上角带有取消按钮,带有不同长度的线条,并且在选择任何内容时浮动提示。
英文:
How to make a the dialog choose box like this custom dialog with cancel button on the top right corner and lines with different lengths and floating hint when there is chosen anything in android studio.
答案1
得分: 1
以下是翻译好的部分:
要在屏幕的右上角显示所需的对话框,请使用以下代码:
Window window = alertdialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.TOP | Gravity.RIGHT;
wlp.width = ViewGroup.LayoutParams.MATCH_PARENT;
wlp.y = 100; // 如果您想要从顶部设置边距
// wlp.x = 100; // 如果您想要从左侧设置边距
wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wlp);
英文:
To display the required dialog box top right of the screen use this code :
Window window = alertdialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.TOP | Gravity.RIGHT;
wlp.width = ViewGroup.LayoutParams.MATCH_PARENT;
wlp.y=100 ; //if you want give margin from top
//wlp.x=100 ; //if you want give margin from left
wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wlp);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论