How to make a the dialog choose box like this custom dialog with cancel button on the top right corner like this one?

huangapple go评论90阅读模式
英文:

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 like this one?

英文:

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.How to make a the dialog choose box like this custom dialog with cancel button on the top right corner like this one?

答案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); 

huangapple
  • 本文由 发表于 2020年10月6日 04:04:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/64215446.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定