社区
Android
帖子详情
怎么设置dialog 显示在指定位置上
jjxoyzy
2011-06-13 11:52:53
比如我想把dialog 设置在 屏幕的 200,150,这个点上,怎么设置?
...全文
5463
5
打赏
收藏
怎么设置dialog 显示在指定位置上
比如我想把dialog 设置在 屏幕的 200,150,这个点上,怎么设置?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
zhuyangyang123
2012-09-17
打赏
举报
回复
楼主真的应该结贴的,这样别人还知道谁的答案是对的可以参考一下,若都不对,楼主把你的贴上来说说解决办法。。。哎。。。。
Micky米
2011-06-15
打赏
举报
回复
protected void setDialogAttributes(Dialog dlg, boolean right, int xpos, int ypos){
try{
Window win = dlg.getWindow();
WindowManager.LayoutParams wl = win.getAttributes();
if(right){
wl.gravity = android.view.Gravity.RIGHT | android.view.Gravity.TOP;
}else{
wl.gravity = android.view.Gravity.LEFT | android.view.Gravity.TOP;
}
wl.x = xpos;
wl.y = ypos;
wl.height = 500;
wl.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS ;
wl.alpha = 1.0f;
wl.dimAmount = 0.0f;
win.setAttributes(wl);
}
catch(Exception e){
Log.e(TAG, "setWinAttributes", e);
}
}
lizhengjun2010
2011-06-13
打赏
举报
回复
AlertDialog dlg = new AlertDialog.Builder(this).create();
Window w=dlg.getWindow();
WindowManager.LayoutParams lp =w.getAttributes();
//显示位置
lp.x=200;
lp.y=150;
wuyu637
2011-06-13
打赏
举报
回复
if (spaceToWrapAt >= 0) {
wrappedLine.append(str.substring(offset, spaceToWrapAt));
wrappedLine.append(newLineStr);
offset = spaceToWrapAt + 1;
} else {
wrappedLine.append(str.substring(offset));
offset = inputLineLength;
}
}
}
}
// Whatever is left in line is short enough to just pass through
wrappedLine.append(str.substring(offset));
return wrappedLine.toString();
}
wuyu637
2011-06-13
打赏
举报
回复
系统中所有对话框,默认布局方式都是居中显示,如果想自定义显示位置可以考虑如下方式:
……
Window mWindow = dialog.getWindow();
WindowManager.LayoutParams lp = mWindow.getAttributes();
lp.x= xxx;
lp.y= xxx;
复制代码
缺省居中lp.x=0,lp.y=0
新坐标 x小于0左移,大于0右移;y小于0上移,大于0下移
@Override
protected void onDestroy() {
super.onDestroy();
android.os.Process.killProcess(android.os.Process.myPid());
}
public static String wrap(String str, int wrapLength, String newLineStr, boolean wrapLongWords) {
if (str == null) {
return null;
}
if (newLineStr == null) {
newLineStr = System.getProperty("line.separator");
}
if (wrapLength < 1) {
wrapLength = 1;
}
int inputLineLength = str.length();
int offset = 0;
StringBuffer wrappedLine = new StringBuffer(inputLineLength + 32);
while ((inputLineLength - offset) > wrapLength) {
if (str.charAt(offset) == ' ') {
offset++;
continue;
}
int spaceToWrapAt = str.lastIndexOf(' ', wrapLength + offset);
if (spaceToWrapAt >= offset) {
// normal case
wrappedLine.append(str.substring(offset, spaceToWrapAt));
wrappedLine.append(newLineStr);
offset = spaceToWrapAt + 1;
} else {
// really long word or URL
if (wrapLongWords) {
// wrap really long word one line at a time
wrappedLine.append(str.substring(offset, wrapLength + offset));
wrappedLine.append(newLineStr);
offset += wrapLength;
} else {
// do not wrap really long word, just extend beyond limit
spaceToWrapAt = str.indexOf(' ', wrapLength + offset);
android
dialog
指定
位置
,android--自己定义Progress
Dialog
显示
位置
(其他
Dialog
子类都能够
设置
)...
博客介绍了Android中
Dialog
的
显示
位置
设置
方法。普通情况下,系统默认
Dialog
显示
在屏幕居中。还可
设置
其
显示
在屏幕底部,也能进一步
设置
距离底部一定像素,文中给出了相应的代码示例。
android——代码实现在
指定
位置
显示
View
这篇博客介绍了如何在Android中实现长按TextView后在
指定
位置
显示
Dialog
的效果。通过利用getLocationOnScreen方法获取坐标,并使用PopupWindow的showAtLocation方法结合Gravity
设置
显示
位置
。
dialog
android 定位,在屏幕android上更改
Dialog
的
位置
博客围绕在Android屏幕上更改
Dialog
位置
展开。先给出创建简单Alert
Dialog
的代码,其默认
显示
在屏幕中心。接着提供了8种解决方案,包括
设置
重力参数、
指定
x和y
位置
等,可将对话框
显示
在底部、顶部操作栏下等不同
位置
。
更改
dialog
样式activity在屏幕中
显示
的
位置
本文介绍了一种通过修改DecorView在PhoneWindow中的
位置
参数来调整
Dialog
样式
显示
位置
的方法。具体实现包括
设置
gravity属性为左上角对齐,并
指定
具体的x、y坐标及宽度高度。
jquery 控件学习
dialog
位置
本文介绍如何使用jQuery UI的
dialog
插件来
设置
对话框的
位置
。通过
指定
距离左侧和顶部的像素值,可以精确控制对话框在网页上的
显示
位置
。
Android
80,493
社区成员
91,375
社区内容
发帖
与我相关
我的任务
Android
移动平台 Android
复制链接
扫一扫
分享
社区描述
移动平台 Android
android
android-studio
androidx
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章