本文整理匯總了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!");
}
}