• 普通doalog内容区域外恢复点击事件,去除遮罩层


    AlertDialog alertDialog = new AlertDialog
    .Builder(this)
    .setTitle("请点击播放的舞美效果")
    //列表选择
    .setItems(danceName, new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    tcpClient.setCode(getOne(danceName[which]).getCode());
    tcpClient.tcpStart();
    mSpinnerEight.setText(danceName[which]);
    try {
    Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
    field.setAccessible(true);
    //设置mShowing值,欺骗android系统
    field.set(dialog, false);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    })
    .setPositiveButton("关闭",
    new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    try {
    Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
    field.setAccessible(true);
    //设置mShowing值,欺骗android系统
    field.set(dialog, true);
    } catch (Exception e) {
    e.printStackTrace();
    }
    dialog.dismiss();
    }
    }).create();
    alertDialog.show();
    Window dialogWindow = alertDialog.getWindow();
    dialogWindow.setGravity(Gravity.BOTTOM | Gravity.LEFT);
    dialogWindow.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);//恢复dialog区域外部的功能
    dialogWindow.setDimAmount(0f);//去除遮罩层
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    lp.width=1008;//定义宽度
    lp.height=900;//定义高度
    lp.x = 61;
    lp.y = 100; //设置出现的高度,距离底部
    dialogWindow.setAttributes(lp);
  • 相关阅读:
    ios 学习小笔记
    object c 2.0 @property属性
    uiPickerView 滚动盘
    ios 文件操作
    ios多窗体项目
    Linux命令
    Mina的使用
    设计模式学习总结访问者模式(Visitor Method)
    socket, nio socket 及nio socket框架MINA总结
    UML类图与类的关系详解UML一波流系列(转转)
  • 原文地址:https://www.cnblogs.com/jhfm-hlg/p/13224423.html
Copyright © 2020-2023  润新知