• 普通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);
  • 相关阅读:
    video 自动循环播放
    C. Kefa and Park
    B. Random Teams(数学题)
    B. Books(水题)
    dd爱科学1.0(牛客)
    B. WeirdSort
    B. The Cake Is a Lie
    优先队列 priority_queue
    C. A-B Palindrome
    B. Fedor and New Game(位运算)
  • 原文地址:https://www.cnblogs.com/jhfm-hlg/p/13224423.html
Copyright © 2020-2023  润新知