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


Java Dialog.getWindow方法代码示例

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


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

示例1: onPreExecute

import android.app.Dialog; //导入方法依赖的package包/类
@Override
protected void onPreExecute() {
    isFinalizing = true;
    recordFinish = true;
    runAudioThread = false;

    //创建处理进度条
    creatingProgress = new Dialog(FFmpegRecorderActivity.this, R.style.Dialog_loading_noDim);
    Window dialogWindow = creatingProgress.getWindow();
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    lp.width = (int) (getResources().getDisplayMetrics().density * 240);
    lp.height = (int) (getResources().getDisplayMetrics().density * 80);
    lp.gravity = Gravity.CENTER;
    dialogWindow.setAttributes(lp);
    creatingProgress.setCanceledOnTouchOutside(false);
    creatingProgress.setContentView(R.layout.activity_recorder_progress);

    progress = (TextView) creatingProgress.findViewById(R.id.recorder_progress_progresstext);
    bar = (ProgressBar) creatingProgress.findViewById(R.id.recorder_progress_progressbar);
    creatingProgress.show();


    //txtTimer.setVisibility(View.INVISIBLE);
    //handler.removeCallbacks(mUpdateTimeTask);
    super.onPreExecute();
}
 
开发者ID:feigxj,项目名称:VideoRecorder-master,代码行数:27,代码来源:FFmpegRecorderActivity.java

示例2: onCreateDialog

import android.app.Dialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // the content
    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    // creating the fullscreen dialog
    final Dialog dialog = new Dialog(getContext());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    if (dialog.getWindow() != null) {
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.getWindow().setLayout(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    dialog.setCanceledOnTouchOutside(false);

    return dialog;
}
 
开发者ID:n1rocket,项目名称:eggs-android,代码行数:24,代码来源:BaseDialog.java

示例3: showDialogForAvatarOrDismiss

import android.app.Dialog; //导入方法依赖的package包/类
private void showDialogForAvatarOrDismiss(boolean showOrNotShow)
{
    if (showOrNotShow)
    {
        avatarClickDialog = new Dialog(getActivity(), R.style.Theme_Light_Dialog);
        dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.layout_dialog,null);
        //获得dialog的window窗口
        Window window = avatarClickDialog.getWindow();
        //设置dialog在屏幕底部
        window.setGravity(Gravity.BOTTOM);
        //设置dialog弹出时的动画效果,从屏幕底部向上弹出
        window.setWindowAnimations(R.style.dialogStyle);
        window.getDecorView().setPadding(0, 0, 0, 0);
        //获得window窗口的属性
        android.view.WindowManager.LayoutParams lp = window.getAttributes();
        //设置窗口宽度为充满全屏
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        //设置窗口高度为包裹内容
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        //将设置好的属性set回去
        window.setAttributes(lp);
        //将自定义布局加载到dialog上
        avatarClickDialog.setContentView(dialogView);
        //初始化Button
        btn_camera= (Button) dialogView.findViewById(R.id.btn_camera);
        btn_album= (Button) dialogView.findViewById(R.id.btn_album);
        btn_cancel= (Button) dialogView.findViewById(R.id.btn_cancel);
        //监听Button
        btn_camera.setOnClickListener(this);
        btn_album.setOnClickListener(this);
        btn_cancel.setOnClickListener(this);
        avatarClickDialog.show();
    }
    else
    {
        avatarClickDialog.dismiss();
    }
}
 
开发者ID:WindFromFarEast,项目名称:SmartButler,代码行数:39,代码来源:UserFragment.java

示例4: NormalAlertDialog

import android.app.Dialog; //导入方法依赖的package包/类
public NormalAlertDialog(Builder builder) {

        this.mBuilder = builder;
        mDialog = new Dialog(mContext, R.style.NormalDialogStyle);
        mDialogView = View.inflate(mContext, R.layout.widget_dialog_normal, null);
        mTitle = (TextView) mDialogView.findViewById(R.id.dialog_normal_title);
        mContent = (TextView) mDialogView.findViewById(R.id.dialog_normal_content);
        mLeftBtn = (Button) mDialogView.findViewById(R.id.dialog_normal_leftbtn);
        mRightBtn = (Button) mDialogView.findViewById(R.id.dialog_normal_rightbtn);
        mSingleBtn = (Button) mDialogView.findViewById(R.id.dialog_normal_midbtn);
        mLine = (TextView) mDialogView.findViewById(R.id.dialog_normal_line);
        mDialogView.setMinimumHeight((int) (ScreenSizeUtils.getInstance(mContext).getScreenHeight
                () * builder.getHeight()));
        mDialog.setContentView(mDialogView);

        Window dialogWindow = mDialog.getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = (int) (ScreenSizeUtils.getInstance(mContext).getScreenWidth() * builder.getWidth());
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.gravity = Gravity.CENTER;
        dialogWindow.setAttributes(lp);

        initDialog(builder);
    }
 
开发者ID:wp521,项目名称:MyFire,代码行数:25,代码来源:NormalAlertDialog.java

示例5: onCreateDialog

import android.app.Dialog; //导入方法依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    if (dialog != null && dialog.getWindow() != null) {
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }
    return dialog;
}
 
开发者ID:ttpho,项目名称:TimePicker,代码行数:9,代码来源:TimePickerDialog.java

示例6: 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:weileng11,项目名称:KUtils-master,代码行数:36,代码来源:ToolUtils.java

示例7: setBottom

import android.app.Dialog; //导入方法依赖的package包/类
/**
 * 让Dialog从底部出现/宽度全屏
 *
 * @param dialog
 * @param rootView
 */
public static void setBottom(Dialog dialog, View rootView) {
    Window window = dialog.getWindow();
    // 在5.0以上手机必须加上这句代码
    window.setBackgroundDrawableResource(android.R.color.transparent);
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    window.setAttributes(lp);
    window.setGravity(Gravity.BOTTOM);  //此处可以设置dialog显示的位置
    window.setWindowAnimations(R.style.BottomDialogStyle);  //添加动画
    window.setContentView(rootView);//布局
}
 
开发者ID:liying2008,项目名称:Simpler,代码行数:18,代码来源:DialogUtil.java

示例8: EnsureDialog

import android.app.Dialog; //导入方法依赖的package包/类
public EnsureDialog(Context context) {
    this.context = context;
    final WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    display = windowManager.getDefaultDisplay();
    dialog = new Dialog(context, R.style.Custom_Dialog_Style);
    dialogWindow = dialog.getWindow();

}
 
开发者ID:SiberiaDante,项目名称:CustomDialog,代码行数:9,代码来源:EnsureDialog.java

示例9: getToken

import android.app.Dialog; //导入方法依赖的package包/类
private IBinder getToken() {
    final Dialog dialog = getWindow();
    if (dialog == null) {
        return null;
    }
    final Window window = dialog.getWindow();
    if (window == null) {
        return null;
    }
    return window.getAttributes().token;
}
 
开发者ID:YehtutHl,项目名称:myan,代码行数:12,代码来源:SmartMyan.java

示例10: KeyboardUtil

import android.app.Dialog; //导入方法依赖的package包/类
private KeyboardUtil(Activity activity, Dialog dialog, String tag, View contentView) {
    this.mActivity = activity;
    this.mWindow = dialog != null ? dialog.getWindow() : activity.getWindow();
    this.mDecorView = activity.getWindow().getDecorView();
    this.mContentView = contentView != null ? contentView
            : mWindow.getDecorView().findViewById(android.R.id.content);
    if (!mContentView.equals(mDecorView.findViewById(android.R.id.content)))
        this.mFlag = true;
}
 
开发者ID:AriesHoo,项目名称:TitleBarView,代码行数:10,代码来源:KeyboardUtil.java

示例11: setDialogSize

import android.app.Dialog; //导入方法依赖的package包/类
public static void setDialogSize(@NonNull Context context, @NonNull Dialog dialog) {
    int maxWidth = ResourceUtils.dimen(context, R.dimen.dialog_max_size);
    int padding = ResourceUtils.dimen(context, R.dimen.dialog_padding);
    int screenSize = DeviceUtils.getScreenWidth(context);
    if (maxWidth > screenSize - 2 * padding) {
        maxWidth = screenSize - 2 * padding;
    }
    Window window = dialog.getWindow();
    if (window != null) {
        window.setLayout(maxWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
    }
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:13,代码来源:BrowserDialog.java

示例12: showDialogForView

import android.app.Dialog; //导入方法依赖的package包/类
private void showDialogForView(View view) {
    mDialog = new Dialog(mActivity) {
        @Override
        public void onWindowFocusChanged(boolean hasFocus) {
            super.onWindowFocusChanged(hasFocus);
            if (!hasFocus) super.dismiss();
        }
    };
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setCanceledOnTouchOutside(true);
    mDialog.addContentView(view,
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                          LinearLayout.LayoutParams.MATCH_PARENT));
    mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mItemSelectedCallback.onItemSelected("");
        }
    });

    Window window = mDialog.getWindow();
    if (!DeviceFormFactor.isTablet(mActivity)) {
        // On smaller screens, make the dialog fill the width of the screen,
        // and appear at the top.
        window.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
        window.setGravity(Gravity.TOP);
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                         ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    mDialog.show();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:33,代码来源:ItemChooserDialog.java

示例13: onViewCreated

import android.app.Dialog; //导入方法依赖的package包/类
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Dialog dialog = getDialog();
    if (dialog != null) {
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        Window window = dialog.getWindow();
        if (window != null) {
            window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            window.getAttributes().windowAnimations = R.style.DialogAnimation;
        }
    }
}
 
开发者ID:rudsonlive,项目名称:liveomvp,代码行数:15,代码来源:BaseDialog.java

示例14: onActivityCreated

import android.app.Dialog; //导入方法依赖的package包/类
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Dialog dialog = getDialog();
    Window window = dialog.getWindow();
    window.setGravity(80);
    LayoutParams lp = dialog.getWindow().getAttributes();
    lp.width = -1;
    window.setAttributes(lp);
    window.setWindowAnimations(R.style.de);
    window.setBackgroundDrawable(new ColorDrawable(0));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:StepGiftFragment.java

示例15: displayYoutubeIdSearchDialog

import android.app.Dialog; //导入方法依赖的package包/类
private void displayYoutubeIdSearchDialog() {
    final Dialog dialog = new Dialog(_context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_edittext);

    TextView titleView = dialog.findViewById(R.id.dialog_title);
    titleView.setText(R.string.searchYoutube);

    TextView promptView = dialog.findViewById(R.id.dialog_prompt);
    promptView.setText(R.string.promptEnterSearch);

    final EditText inputEditText = dialog.findViewById(R.id.dialog_edittext);

    Button closeButton = dialog.findViewById(R.id.dialog_button_close);
    closeButton.setText(R.string.search);
    closeButton.setOnClickListener(v -> {
        String input = inputEditText.getText().toString();

        if (input.length() == 0) {
            Logger.getInstance().Error(TAG, "Input has invalid length 0!");
            Toasty.error(_context, "Input has invalid length 0!", Toast.LENGTH_LONG).show();
            return;
        }

        searchYoutubeVideos(input);
    });

    dialog.setCancelable(true);
    dialog.show();

    Window window = dialog.getWindow();
    if (window != null) {
        window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    } else {
        Logger.getInstance().Warning(TAG, "Window is null!");
    }
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:38,代码来源:MediaServerActivity.java


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