本文整理汇总了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();
}
示例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;
}
示例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();
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);//布局
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例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;
}
}
}
示例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));
}
示例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!");
}
}