android.view.Window.getAttributes()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(396)

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

Window.getAttributes介绍

暂无

代码示例

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

public static boolean hasStatusBar(Activity activity) {
  WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
  if ((attrs.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
    return false;
  } else {
    return true;
  }
}

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

@Override public void onStart() {
  super.onStart();

  Window window = getDialog().getWindow();
  WindowManager.LayoutParams windowParams = window.getAttributes();
  windowParams.dimAmount = 0.90f;
  windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
  window.setAttributes(windowParams);
}

代码示例来源:origin: smuyyh/BookReader

@Override
  public void onAnimationUpdate(ValueAnimator animation) {
    WindowManager.LayoutParams params = window.getAttributes();
    params.alpha = (Float) animation.getAnimatedValue();
    window.setAttributes(params);
  }
});

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

Window window = getWindow();

// Enable status bar translucency (requires API 19)
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

// Disable status bar translucency (requires API 19)
window.getAttributes().flags &= (~WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

// Set a color (requires API 21)
window.setStatusBarColor(Color.RED);

代码示例来源:origin: smuyyh/BookReader

private void lightoff() {
  WindowManager.LayoutParams lp = mActivity.getWindow().getAttributes();
  lp.alpha = 0.3f;
  mActivity.getWindow().setAttributes(lp);
}

代码示例来源:origin: smuyyh/BookReader

private void lightoff() {
  WindowManager.LayoutParams lp = mActivity.getWindow().getAttributes();
  lp.alpha = 0.3f;
  mActivity.getWindow().setAttributes(lp);
}

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

public static void setFullScreen(Activity activity) {
  WindowManager.LayoutParams params = activity.getWindow()
      .getAttributes();
  params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
  activity.getWindow().setAttributes(params);
  activity.getWindow().addFlags(
      WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

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

public static void cancelFullScreen(Activity activity) {
  WindowManager.LayoutParams params = activity.getWindow()
      .getAttributes();
  params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
  activity.getWindow().setAttributes(params);
  activity.getWindow().clearFlags(
      WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

代码示例来源:origin: smuyyh/BookReader

private void lighton() {
  WindowManager.LayoutParams lp = mActivity.getWindow().getAttributes();
  lp.alpha = 1.0f;
  mActivity.getWindow().setAttributes(lp);
}

代码示例来源:origin: smuyyh/BookReader

private void lighton() {
  WindowManager.LayoutParams lp = mActivity.getWindow().getAttributes();
  lp.alpha = 1.0f;
  mActivity.getWindow().setAttributes(lp);
}

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

/**
 * 全屏,并且沉侵式状态栏
 *
 * @param activity
 */
public static void statuInScreen(Activity activity) {
  WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
  attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
  activity.getWindow().setAttributes(attrs);
  activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
  activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle b) {
  Window window = getDialog().getWindow();

  // set "origin" to top left corner, so to speak
  window.setGravity(Gravity.TOP|Gravity.LEFT);

  // after that, setting values for x and y works "naturally"
  WindowManager.LayoutParams params = window.getAttributes();
  params.x = 300;
  params.y = 100;
  window.setAttributes(params);

  Log.d(TAG, String.format("Positioning DialogFragment to: x %d; y %d", params.x, params.y));
}

代码示例来源: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: CarGuo/GSYVideoPlayer

public void initList(List<SwitchVideoModel> data, OnListItemClickListener onItemClickListener) {
  this.onItemClickListener = onItemClickListener;
  this.data = data;
  LayoutInflater inflater = LayoutInflater.from(mContext);
  View view = inflater.inflate(R.layout.switch_video_dialog, null);
  listView = (ListView) view.findViewById(R.id.switch_dialog_list);
  setContentView(view);
  adapter = new ArrayAdapter<>(mContext, R.layout.switch_video_dialog_item, data);
  listView.setAdapter(adapter);
  listView.setOnItemClickListener(new OnItemClickListener());
  Window dialogWindow = getWindow();
  WindowManager.LayoutParams lp = dialogWindow.getAttributes();
  DisplayMetrics d = mContext.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
  lp.width = (int) (d.widthPixels * 0.8); // 高度设置为屏幕的0.6
  dialogWindow.setAttributes(lp);
}

代码示例来源:origin: smuyyh/BookReader

protected void showStatusBar() {
  WindowManager.LayoutParams attrs = getWindow().getAttributes();
  attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
  getWindow().setAttributes(attrs);
  if(statusBarView != null){
    statusBarView.setBackgroundColor(statusBarColor);
  }
}

代码示例来源:origin: smuyyh/BookReader

protected void hideStatusBar() {
  WindowManager.LayoutParams attrs = getWindow().getAttributes();
  attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
  getWindow().setAttributes(attrs);
  if(statusBarView != null){
    statusBarView.setBackgroundColor(Color.TRANSPARENT);
  }
}

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

//show the dialog first
AlertDialog dialog = new AlertDialog.Builder(this)
    .setTitle("Test Dialog")
    .setMessage("This should expand to the full width")
    .show();
//Grab the window of the dialog, and change the width
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
Window window = dialog.getWindow();
lp.copyFrom(window.getAttributes());
//This makes the dialog take up the full width
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(lp);

代码示例来源:origin: rey5137/material

public Dialog(Context context, int style) {
  super(context, style);
  //Override style to ensure not show window's title or background.
  //TODO: find a way to ensure windowIsFloating attribute is false.
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setBackgroundDrawable(BlankDrawable.getInstance());
  WindowManager.LayoutParams layout = getWindow().getAttributes();
  layout.width = ViewGroup.LayoutParams.MATCH_PARENT;
  layout.height = ViewGroup.LayoutParams.MATCH_PARENT;
  layout.windowAnimations = R.style.DialogNoAnimation;
  getWindow().setAttributes(layout);
  init(context, style);
}

代码示例来源:origin: rey5137/material

public BottomSheetDialog(Context context, int style) {
  super(context, style);
  //Override style to ensure not show window's title or background.
  //TODO: find a way to ensure windowIsFloating attribute is false.
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setBackgroundDrawable(BlankDrawable.getInstance());
  WindowManager.LayoutParams layout = getWindow().getAttributes();
  layout.width = ViewGroup.LayoutParams.MATCH_PARENT;
  layout.height = ViewGroup.LayoutParams.MATCH_PARENT;
  layout.windowAnimations = R.style.DialogNoAnimation;
  getWindow().setAttributes(layout);
  init(context, style);
}

代码示例来源:origin: facebook/facebook-android-sdk

@Override
public void onAttachedToWindow() {
  isDetached = false;
  if (Utility.mustFixWindowParamsForAutofill(getContext())
      && windowParams != null && windowParams.token == null) {
    windowParams.token = getOwnerActivity().getWindow().getAttributes().token;
    Utility.logd(LOG_TAG, "Set token on onAttachedToWindow(): " + windowParams.token);
  }
  super.onAttachedToWindow();
}

相关文章

Window类方法