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

x33g5p2x  于2022-01-15 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(447)

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

Activity.getWindow介绍

暂无

代码示例

代码示例来源:origin: mikepenz/MaterialDrawer

public KeyboardUtil(Activity act, View contentView) {
  this.decorView = act.getWindow().getDecorView();
  this.contentView = contentView;
  //only required on newer android versions. it was working on API level 19
  if (Build.VERSION.SDK_INT >= 19) {
    decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
  }
}

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

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

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

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

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

/**
 * BindView annotated fields and methods in the specified {@link Activity}. The current content
 * view is used as the view root.
 *
 * @param target Target activity for view binding.
 */
@NonNull @UiThread
public static Unbinder bind(@NonNull Activity 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 Activity} as the view root.
 *
 * @param target Target class for view binding.
 * @param source Activity on which IDs will be looked up.
 */
@NonNull @UiThread
public static Unbinder bind(@NonNull Object target, @NonNull Activity source) {
 View sourceView = source.getWindow().getDecorView();
 return bind(target, sourceView);
}

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

/**
 * Invoke this method to unregister a view hierarchy.
 * 
 * @param activity
 *            The activity whose view hierarchy/window to unregister
 * 
 * @see #addWindow(Activity)
 * @see #removeWindow(View)
 */
public void removeWindow(Activity activity) {
  removeWindow(activity.getWindow().getDecorView());
}

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

/**
 * Invoke this method to change the currently focused window.
 * 
 * @param activity
 *            The activity whose view hierarchy/window hasfocus, or null to
 *            remove focus
 */
public void setFocusedWindow(Activity activity) {
  setFocusedWindow(activity.getWindow().getDecorView());
}

代码示例来源:origin: scwang90/SmartRefreshLayout

/** 设置状态栏darkMode,字体颜色及icon变黑(目前支持MIUI6以上,Flyme4以上,Android M以上) */
public static void darkMode(Activity activity) {
  darkMode(activity.getWindow(), DEFAULT_COLOR, DEFAULT_ALPHA);
}

代码示例来源:origin: nickbutcher/plaid

@Override
  public void onTransitionEnd(Transition transition) {
    // we only want these content transitions in certain cases so clear out when done.
    host.getWindow().setReenterTransition(null);
  }
});

代码示例来源:origin: scwang90/SmartRefreshLayout

public static void immersive(Activity activity, int color) {
  immersive(activity.getWindow(), color, 1f);
}

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

private static boolean isDecorViewOfActivity(View view, List<WeakReference<Activity>> references) {
 Util.throwIfNull(references);
 for (WeakReference<Activity> reference : references) {
  Activity activity = reference.get();
  if (activity == null) {
   continue;
  }
  if (activity.getWindow().getDecorView() == view) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: nickbutcher/plaid

public SystemChromeFader(Activity activity) {
  this.activity = activity;
  statusBarAlpha = Color.alpha(activity.getWindow().getStatusBarColor());
  navBarAlpha = Color.alpha(activity.getWindow().getNavigationBarColor());
  fadeNavBar = ViewUtils.isNavBarOnBottom(activity);
}

代码示例来源:origin: scwang90/SmartRefreshLayout

public static void darkMode(Activity activity, boolean dark) {
  if (isFlyme4Later()) {
    darkModeForFlyme4(activity.getWindow(), dark);
  } else if (isMIUI6Later()) {
    darkModeForMIUI6(activity.getWindow(), dark);
  } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    darkModeForM(activity.getWindow(), dark);
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

public static void immersive(Activity activity, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) {
  immersive(activity.getWindow(), color, alpha);
}

代码示例来源:origin: scwang90/SmartRefreshLayout

public static void darkMode(Activity activity, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) {
  darkMode(activity.getWindow(), color, alpha);
}

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

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

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

@Before
public void setUp() throws Exception {
 activity = Robolectric.setupActivity(Activity.class);
 window = activity.getWindow();
}

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

@Test
public void getFlag_shouldReturnWindowFlags() throws Exception {
 Activity activity = Robolectric.buildActivity(Activity.class).create().get();
 Window window = activity.getWindow();
 assertThat(shadowOf(window).getFlag(WindowManager.LayoutParams.FLAG_FULLSCREEN)).isFalse();
 window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
 assertThat(shadowOf(window).getFlag(WindowManager.LayoutParams.FLAG_FULLSCREEN)).isTrue();
 window.setFlags(WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
 assertThat(shadowOf(window).getFlag(WindowManager.LayoutParams.FLAG_FULLSCREEN)).isTrue();
}

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

@Test
public void getTitle_shouldReturnWindowTitle() throws Exception {
 Activity activity = Robolectric.buildActivity(Activity.class).create().get();
 Window window = activity.getWindow();
 window.setTitle("My Window Title");
 assertThat(shadowOf(window).getTitle()).isEqualTo("My Window Title");
}

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

@Test
public void getProgressBar_returnsTheProgressBar() {
 Activity activity = Robolectric.buildActivity(TestActivity.class).create().get();
 ProgressBar progress = shadowOf(activity.getWindow()).getProgressBar();
 assertThat(progress.getVisibility()).isEqualTo(View.INVISIBLE);
 activity.setProgressBarVisibility(true);
 assertThat(progress.getVisibility()).isEqualTo(View.VISIBLE);
 activity.setProgressBarVisibility(false);
 assertThat(progress.getVisibility()).isEqualTo(View.GONE);
}

相关文章

微信公众号

最新文章

更多

Activity类方法