android.app.Dialog.getWindow()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(433)

本文整理了Java中android.app.Dialog.getWindow()方法的一些代码示例,展示了Dialog.getWindow()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dialog.getWindow()方法的具体详情如下:
包路径:android.app.Dialog
类名称:Dialog
方法名:getWindow

Dialog.getWindow介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
 Dialog dialog = super.onCreateDialog(savedInstanceState);

 // request a window without the title
 dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
 return dialog;
}

代码示例来源:origin: stackoverflow.com

@Override
public void onStart()
{
  super.onStart();
  Dialog dialog = getDialog();
  if (dialog != null)
  {
    int width = ViewGroup.LayoutParams.MATCH_PARENT;
    int height = ViewGroup.LayoutParams.MATCH_PARENT;
    dialog.getWindow().setLayout(width, height);
  }
}

代码示例来源:origin: JessYanCoding/MVPArms

public static void showSoftKeyboard(Dialog dialog) {
  dialog.getWindow().setSoftInputMode(4);
}

代码示例来源:origin: JakeWharton/butterknife

/**
 * BindView annotated fields and methods in the specified {@code target} using the {@code source}
 * {@link Dialog} as the view root.
 *
 * @param target Target class for view binding.
 * @param source Dialog on which IDs will be looked up.
 */
@NonNull @UiThread
public static Unbinder bind(@NonNull Object target, @NonNull Dialog source) {
 View sourceView = source.getWindow().getDecorView();
 return bind(target, sourceView);
}

代码示例来源:origin: JakeWharton/butterknife

/**
 * BindView annotated fields and methods in the specified {@link Dialog}. The current content
 * view is used as the view root.
 *
 * @param target Target dialog for view binding.
 */
@NonNull @UiThread
public static Unbinder bind(@NonNull Dialog target) {
 View sourceView = target.getWindow().getDecorView();
 return bind(target, sourceView);
}

代码示例来源:origin: JakeWharton/butterknife

/**
 * BindView annotated fields and methods in the specified {@link Dialog}. The current content
 * view is used as the view root.
 *
 * @param target Target dialog for view binding.
 */
@NonNull @UiThread
public static Unbinder bind(@NonNull Dialog target) {
 View sourceView = target.getWindow().getDecorView();
 return bind(target, sourceView);
}

代码示例来源:origin: JakeWharton/butterknife

/**
 * BindView annotated fields and methods in the specified {@code target} using the {@code source}
 * {@link Dialog} as the view root.
 *
 * @param target Target class for view binding.
 * @param source Dialog on which IDs will be looked up.
 */
@NonNull @UiThread
public static Unbinder bind(@NonNull Object target, @NonNull Dialog source) {
 View sourceView = source.getWindow().getDecorView();
 return bind(target, sourceView);
}

代码示例来源:origin: facebook/stetho

@Override
protected void onGetChildren(Dialog element, Accumulator<Object> children) {
 Window window = element.getWindow();
 if (window != null) {
  children.store(window);
 }
}

代码示例来源:origin: lipangit/JiaoZiVideoPlayer

public Dialog createDialogWithView(View localView) {
  Dialog dialog = new Dialog(getContext(), R.style.jz_style_dialog_progress);
  dialog.setContentView(localView);
  Window window = dialog.getWindow();
  window.addFlags(Window.FEATURE_ACTION_BAR);
  window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
  window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
  window.setLayout(-2, -2);
  WindowManager.LayoutParams localLayoutParams = window.getAttributes();
  localLayoutParams.gravity = Gravity.CENTER;
  window.setAttributes(localLayoutParams);
  return dialog;
}

代码示例来源:origin: TeamNewPipe/NewPipe

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  final Dialog dialog = super.onCreateDialog(savedInstanceState);
  //remove title
  final Window window = dialog.getWindow();
  if (window != null) {
    window.requestFeature(Window.FEATURE_NO_TITLE);
  }
  return dialog;
}

代码示例来源:origin: robolectric/robolectric

public CharSequence getTitle() {
 ShadowWindow shadowWindow = Shadow.extract(realDialog.getWindow());
 return shadowWindow.getTitle();
}

代码示例来源:origin: facebook/stetho

@Nullable
@Override
public View getViewAndBoundsForHighlighting(Dialog element, Rect bounds) {
 final Descriptor.Host host = getHost();
 Window window = null;
 HighlightableDescriptor descriptor = null;
 if (host instanceof AndroidDescriptorHost) {
  window = element.getWindow();
  descriptor = ((AndroidDescriptorHost) host).getHighlightableDescriptor(window);
 }
 return descriptor == null
   ? null
   : descriptor.getViewAndBoundsForHighlighting(window, bounds);
}

代码示例来源:origin: facebook/stetho

@Nullable
 @Override
 public Object getElementToHighlightAtPosition(Dialog element, int x, int y, Rect bounds) {
  final Descriptor.Host host = getHost();
  Window window = null;
  HighlightableDescriptor descriptor = null;

  if (host instanceof AndroidDescriptorHost) {
   window = element.getWindow();
   descriptor = ((AndroidDescriptorHost) host).getHighlightableDescriptor(window);
  }

  return descriptor == null
    ? null
    : descriptor.getElementToHighlightAtPosition(window, x, y, bounds);
 }
}

代码示例来源:origin: aa112901/remusic

@Override
public void onStart() {
  super.onStart();
  //设置fragment高度 、宽度
  int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.71);
  int dialogWidth = (int) (mContext.getResources().getDisplayMetrics().widthPixels * 0.79);
  getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
  getDialog().setCanceledOnTouchOutside(true);
}

代码示例来源:origin: aa112901/remusic

@Override
public void onStart() {
  super.onStart();
  //设置fragment高度 、宽度
  int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.30);
  getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, dialogHeight);
  getDialog().setCanceledOnTouchOutside(true);
}

代码示例来源:origin: aa112901/remusic

@Override
public void onStart() {
  super.onStart();
  //设置fragment高度 、宽度
  int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.6);
  getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, dialogHeight);
  getDialog().setCanceledOnTouchOutside(true);
}

代码示例来源:origin: aa112901/remusic

@Override
public void onStart() {
  super.onStart();
  //设置fragment高度 、宽度
  int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels * 0.65);
  int dialogWidth = (int) (getActivity().getResources().getDisplayMetrics().widthPixels * 0.77);
  getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
  getDialog().setCanceledOnTouchOutside(true);
}

代码示例来源:origin: aa112901/remusic

@Override
public void onStart() {
  super.onStart();
  //设置fragment高度 、宽度
  int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels * 0.56);
  int dialogWidth = (int) (getActivity().getResources().getDisplayMetrics().widthPixels * 0.63);
  getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
  getDialog().setCanceledOnTouchOutside(true);
}

代码示例来源:origin: aa112901/remusic

@Override
public void onStart() {
  super.onStart();
  //设置fragment高度 、宽度
  int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels);
  int dialogWidth = (int) (getActivity().getResources().getDisplayMetrics().widthPixels);
  getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
  getDialog().setCanceledOnTouchOutside(true);
}

代码示例来源:origin: aa112901/remusic

@Override
public void onStart() {
  super.onStart();
  //设置fragment高度 、宽度
  int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels);
  int dialogWidth = (int) (getActivity().getResources().getDisplayMetrics().widthPixels);
  getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
  getDialog().setCanceledOnTouchOutside(true);
}

相关文章