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

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

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

Window.getContext介绍

暂无

代码示例

代码示例来源:origin: hidroh/materialistic

public static void setStatusBarDim(Window window, boolean dim) {
  setStatusBarColor(window, dim ? Color.TRANSPARENT :
      ContextCompat.getColor(window.getContext(),
          AppUtils.getThemedResId(window.getContext(), R.attr.colorPrimaryDark)));
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

ViewGroup contentView = (ViewGroup) window.getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(window.getContext());
if (rootView != null) {
  FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rootView.getLayoutParams();

代码示例来源:origin: jingle1267/android-utils

public Resources getResources() {
    return window.getContext().getResources();
  }
}

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

Window window = getActivity().getWindow();
window.getContext().setTheme(R.style.PreferencesTheme);

代码示例来源:origin: kioko/android-liveData-viewModel

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void setTranslucentStatusBarLollipop(Window window, int color) {
  window.setStatusBarColor(
      window.getContext()
          .getResources()
          .getColor(color));
}

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

@Override
public void onBindHost(ISpringBoardHostStub paramISpringBoardHostStub) {
  Log.d(Constants.TAG, "onBindHost");
  //Store host
  mHost = paramISpringBoardHostStub;
  Context context = paramISpringBoardHostStub.getHostWindow().getContext();
  if (context == null) {
    Log.d(Constants.TAG, "onBindHost: context is null!");
  } else {
    //Intent intent = new Intent(context, MainService.class);
    //context.sendBroadcastAsUser(intent, android.os.Process.myUserHandle());
    //context(intent);
  }
}

代码示例来源:origin: msdx/status-bar-compat

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void setStatusBarColor(Window window, int color) {
  window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  ViewGroup decorViewGroup = (ViewGroup) window.getDecorView();
  View statusBarView = decorViewGroup.findViewWithTag(STATUS_BAR_VIEW_TAG);
  if (statusBarView == null) {
    statusBarView = new StatusBarView(window.getContext());
    statusBarView.setTag(STATUS_BAR_VIEW_TAG);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
        FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.TOP;
    statusBarView.setLayoutParams(params);
    decorViewGroup.addView(statusBarView);
  }
  statusBarView.setBackgroundColor(color);
  StatusBarCompat.internalSetFitsSystemWindows(window, true);
}

代码示例来源:origin: wuhenzhizao/android-titlebar

private KeyboardConflictCompat(Window window) {
  FrameLayout content = (FrameLayout) window.findViewById(android.R.id.content);
  mChildOfContent = content.getChildAt(0);
  mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    public void onGlobalLayout() {
      if (isfirst) {
        contentHeight = mChildOfContent.getHeight();//兼容华为等机型
        isfirst = false;
      }
      possiblyResizeChildOfContent();
    }
  });
  frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
  statusBarHeight = StatusBarUtils.getStatusBarHeight(window.getContext());
}

代码示例来源:origin: Veaer/Glass

public Builder statusBar(Window window) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    Context context = window.getContext().getApplicationContext();
    LocalDisplay.init(context);
    WindowManager.LayoutParams localLayoutParams = window.getAttributes();
    localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
    ViewGroup contentView = (ViewGroup)window.getDecorView().findViewById(android.R.id.content);
    View mStatusBarView = new View(context);
    int height =  LocalDisplay.getStatusHeight(context.getResources());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, height);
    params.gravity = Gravity.TOP;
    mStatusBarView.setLayoutParams(params);
    contentView.addView(mStatusBarView);
    background(mStatusBarView);
  } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Setter windowSetter = SetterFactory.getSystemSetter(window);
    add(windowSetter);
  }
  return this;
}

代码示例来源:origin: HotBitmapGG/LeisureRead

.findViewById(Window.ID_ANDROID_CONTENT);
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(window.getContext());
if (rootView != null) {
 FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rootView.getLayoutParams();

代码示例来源:origin: fodroid/XStatusBarHelper

ViewGroup contentView = (ViewGroup) window.getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(window.getContext());
if (rootView != null) {
  FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rootView.getLayoutParams();

代码示例来源:origin: listenzz/AndroidNavigation

ObjectAnimator animator = ObjectAnimator.ofFloat(statusBarView, "y", -getStatusBarHeight(window.getContext()));
animator.setDuration(200);
animator.setStartDelay(200);

代码示例来源:origin: WeDevelopTeam/HeroVideo-master

.findViewById(Window.ID_ANDROID_CONTENT);
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(window.getContext());
if (rootView != null) {
 FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rootView.getLayoutParams();

代码示例来源:origin: derry/delion

/**
 * Create and show the fullscreen notification toast.
 */
private void showNotificationToast() {
  if (mNotificationToast == null) {
    int resId = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
        ? R.string.immersive_fullscreen_api_notification
        : R.string.fullscreen_api_notification;
    mNotificationToast = Toast.makeText(
        mWindow.getContext(), resId, Toast.LENGTH_LONG);
    mNotificationToast.setGravity(Gravity.TOP | Gravity.CENTER, 0, 0);
  }
  mNotificationToast.show();
}

代码示例来源:origin: listenzz/AndroidNavigation

View statusBarView = decorViewGroup.findViewWithTag("custom_status_bar_tag");
if (statusBarView == null) {
  statusBarView = new View(window.getContext());
  statusBarView.setTag("custom_status_bar_tag");
  FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
      FrameLayout.LayoutParams.MATCH_PARENT, getStatusBarHeight(window.getContext()));
  params.gravity = Gravity.TOP;
  statusBarView.setLayoutParams(params);

代码示例来源:origin: derry/delion

@Override
public void onActivityStateChange(Activity activity, int newState) {
  if (newState == ActivityState.STOPPED) {
    // Exit fullscreen in onStop to ensure the system UI flags are set correctly when
    // showing again (on JB MR2+ builds, the omnibox would be covered by the
    // notification bar when this was done in onStart()).
    setPersistentFullscreenMode(false);
  } else if (newState == ActivityState.STARTED) {
    // Force the controls to be shown until we get an update from a Tab.  This is a
    // workaround for when the renderer is killed but the Tab is not notified.
    mActivityShowToken = showControlsPersistentAndClearOldToken(mActivityShowToken);
  } else if (newState == ActivityState.DESTROYED) {
    ApplicationStatus.unregisterActivityStateListener(this);
    ((BaseChromiumApplication) mWindow.getContext().getApplicationContext())
        .unregisterWindowFocusChangedListener(this);
  }
}

代码示例来源:origin: derry/delion

/**
 * Creates an instance of the fullscreen mode manager.
 * @param activity The activity that supports fullscreen.
 * @param controlContainer Container holding the controls (Toolbar).
 * @param modelSelector The model selector providing access to the current tab.
 * @param resControlContainerHeight The dimension resource ID for the control container height.
 * @param supportsBrowserOverride Whether we want to disable the token system used by the
                 browser.
 */
public ChromeFullscreenManager(Activity activity, ControlContainer controlContainer,
    TabModelSelector modelSelector, int resControlContainerHeight,
    boolean supportsBrowserOverride) {
  super(activity.getWindow(), modelSelector);
  mActivity = activity;
  ApplicationStatus.registerStateListenerForActivity(this, activity);
  ((BaseChromiumApplication) activity.getApplication())
      .registerWindowFocusChangedListener(this);
  mWindow = activity.getWindow();
  mHandler = new FullscreenHandler(this);
  assert controlContainer != null;
  mControlContainer = controlContainer;
  Resources resources = mWindow.getContext().getResources();
  mControlContainerHeight = resources.getDimensionPixelSize(resControlContainerHeight);
  mRendererContentOffset = mControlContainerHeight;
  mSupportsBrowserOverride = supportsBrowserOverride;
  updateControlOffset();
}

代码示例来源:origin: AriesHoo/UIWidget

Context mContext = window.getContext();

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

@Override
public void onActive(Bundle paramBundle) {
  super.onActive(paramBundle);
  //Check if the view is already inflated (reloading)
  if ((!this.mHasActive) && (this.mView != null)) {
    //It is, simply refresh
    refreshView();
  }
  if (!eventBusConnected) {
    initIPC(mHost.getHostWindow().getContext());
  }
  if (date != null) {
    date.setText(TimeAgo.using(lastDate));
  }
  //Store active state
  this.mHasActive = true;
}

代码示例来源:origin: WangDaYeeeeee/GeometricWeather

public static void setStatusBarStyleWithScrolling(Window window, View statusBar, boolean overlap) {
  if (overlap) {
    if (isDarkMode(window.getContext())) {
      // dark mode.
      statusBar.clearAnimation();
      statusBar.startAnimation(new AlphaAnimation(statusBar, statusBar.getAlpha(), 0.2F));
    } else {
      // light mode.
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        statusBar.clearAnimation();
        statusBar.startAnimation(new AlphaAnimation(statusBar, statusBar.getAlpha(), 0.2F));
      } else {
        statusBar.clearAnimation();
        statusBar.startAnimation(new AlphaAnimation(statusBar, statusBar.getAlpha(), 0.1F));
      }
    }
  } else {
    statusBar.clearAnimation();
    statusBar.startAnimation(new AlphaAnimation(statusBar, statusBar.getAlpha(), 0.05F));
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    if (overlap && !isDarkMode(window.getContext())) {
      setDarkTextStatusBar(window);
    } else {
      setStatusBarTranslate(window);
    }
  }
}

相关文章

微信公众号

最新文章

更多

Window类方法