当前位置: 首页>>代码示例>>Java>>正文


Java Dialog.onWindowAttributesChanged方法代码示例

本文整理汇总了Java中android.app.Dialog.onWindowAttributesChanged方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.onWindowAttributesChanged方法的具体用法?Java Dialog.onWindowAttributesChanged怎么用?Java Dialog.onWindowAttributesChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Dialog的用法示例。


在下文中一共展示了Dialog.onWindowAttributesChanged方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: adjustWH

import android.app.Dialog; //导入方法依赖的package包/类
public static void adjustWH( Dialog dialog,  ConfigBean bean ) {
    if (dialog == null){
        return;
    }

    Window window = dialog.getWindow();
    View rootView = window.getDecorView();
    //window.setWindowAnimations(R.style.dialog_center);
    WindowManager.LayoutParams wl = window.getAttributes();

    int width = window.getWindowManager().getDefaultDisplay().getWidth();
    int height = window.getWindowManager().getDefaultDisplay().getHeight();
    int measuredHeight = rootView.getMeasuredHeight();

    float ratio = 0.85f;
    if(bean.type ==DefaultConfig.TYPE_IOS_BOTTOM){
        ratio = 0.95f;
    }else if(bean.type ==DefaultConfig.TYPE_IOS_CENTER_LIST){
        ratio = 0.9f;
    }
    if(width > height){//宽屏
        ratio = 0.5f;
    }

    if(istheTypeOfNotAdjust(bean.type)){
        /*wl.width = ViewGroup.LayoutParams.WRAP_CONTENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;*/
    }else {
       // rootView.setPadding(0,30,0,30);
        wl.width = (int) (width * ratio);
        if (measuredHeight > height* 0.9){
            wl.height = (int) (height* 0.9);
        }
    }

    dialog.onWindowAttributesChanged(wl);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:Tool.java

示例2: setDialogStyle

import android.app.Dialog; //导入方法依赖的package包/类
public static void setDialogStyle(Context context, Dialog dialog, int measuredHeight, BuildBean bean) {
    if (dialog == null) {
        return;
    }
    Window window = dialog.getWindow();
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    window.setGravity(bean.gravity);
    WindowManager.LayoutParams wl = window.getAttributes();
    // 以下这两句是为了保证按钮可以水平满屏
    int width = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
    int height = (int) (((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() * 0.9);
    if (bean.type != DialogConfig.TYPE_MD_LOADING) {
        wl.width = (int) (width * 0.94);  // todo keycode to keep gap
    } else {
        wl.width = ViewGroup.LayoutParams.WRAP_CONTENT;
    }
    wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;  //TODO  一般情况下为wrapcontent,最大值为height*0.9
    if (measuredHeight > height) {
        wl.height = height;
    }
    if (context instanceof Activity) {
        Activity activity1 = (Activity) context;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            if (activity1.isDestroyed()) {
                context = DialogUIUtils.appContext;
            }
        }
    } else {
        wl.type = WindowManager.LayoutParams.TYPE_TOAST;
        //todo keycode to improve window level,同时要让它的后面半透明背景也拦截事件,不要传递到下面去
        //todo 单例化,不然连续弹出两次,只能关掉第二次的
    }
    dialog.onWindowAttributesChanged(wl);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:ToolUtils.java

示例3: setDialogStyle

import android.app.Dialog; //导入方法依赖的package包/类
public static void setDialogStyle(Context context, Dialog dialog, int measuredHeight, BuildBean bean) {
    if (dialog == null) {
        return;
    }
    Window window = dialog.getWindow();
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    window.setGravity(bean.gravity);
    WindowManager.LayoutParams wl = window.getAttributes();
    // 以下这两句是为了保证按钮可以水平满屏
    int width = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
    int height = (int) (((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() * 0.9);
    if (bean.type != CommonConfig.TYPE_MD_LOADING_VERTICAL) {
        wl.width = (int) (width * 0.94);  // todo keycode to keep gap
    } else {
        wl.width = ViewGroup.LayoutParams.WRAP_CONTENT;
    }
    wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;  //TODO  一般情况下为wrapcontent,最大值为height*0.9
    if (measuredHeight > height) {
        wl.height = height;
    }
    if (context instanceof Activity) {
        Activity activity1 = (Activity) context;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            if (activity1.isDestroyed()) {
                context = DialogUIUtils.appContext;
            }
        }
    } else {
        wl.type = WindowManager.LayoutParams.TYPE_TOAST;
        //todo keycode to improve window level,同时要让它的后面半透明背景也拦截事件,不要传递到下面去
        //todo 单例化,不然连续弹出两次,只能关掉第二次的
    }
    dialog.onWindowAttributesChanged(wl);

}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:36,代码来源:ToolUtils.java


注:本文中的android.app.Dialog.onWindowAttributesChanged方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。