当前位置: 首页>>代码示例>>Java>>正文


Java Window.getDecorView方法代码示例

本文整理汇总了Java中android.view.Window.getDecorView方法的典型用法代码示例。如果您正苦于以下问题:Java Window.getDecorView方法的具体用法?Java Window.getDecorView怎么用?Java Window.getDecorView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.Window的用法示例。


在下文中一共展示了Window.getDecorView方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invasionStatusBar

import android.view.Window; //导入方法依赖的package包/类
/**
 * Set the content layout full the StatusBar, but do not hide StatusBar.
 */
public static void invasionStatusBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = activity.getWindow();
        View decorView = window.getDecorView();
        decorView.setSystemUiVisibility(decorView.getSystemUiVisibility()
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }
}
 
开发者ID:yanzhenjie,项目名称:Sofia,代码行数:15,代码来源:Utils.java

示例2: initWindowDecorActionBar

import android.view.Window; //导入方法依赖的package包/类
/**
 * Creates a new ActionBar, locates the inflated ActionBarView,
 * initializes the ActionBar with the view, and sets mActionBar.
 */
private void initWindowDecorActionBar() {
    Window window = getWindow();

    // Initializing the window decor can change window feature flags.
    // Make sure that we have the correct set before performing the test below.
    window.getDecorView();

    if (isChild() || !window.hasFeature(Window.FEATURE_ACTION_BAR) || mActionBar != null) {
        return;
    }

    mActionBar = new WindowDecorActionBar(this);
    mActionBar.setDefaultDisplayHomeAsUpEnabled(mEnableDefaultActionBarUp);

    mWindow.setDefaultIcon(mActivityInfo.getIconResource());
    mWindow.setDefaultLogo(mActivityInfo.getLogoResource());
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:22,代码来源:a.java

示例3: tintStatusBarForDrawer

import android.view.Window; //导入方法依赖的package包/类
/**
 * Android4.4以上的状态栏着色(针对于DrawerLayout)
 * 注:
 * 1.如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性,尤其是DrawerLayout的fitsSystemWindows属性
 * 2.可以版本判断在5.0以上不调用该方法,使用系统自带
 *
 * @param activity Activity对象
 * @param drawerLayout DrawerLayout对象
 * @param statusBarColor 状态栏颜色
 * @param alpha 透明栏透明度[0.0-1.0]
 */
public static void tintStatusBarForDrawer(Activity activity, DrawerLayout drawerLayout,
                                          @ColorInt int statusBarColor,
                                          @FloatRange(from = 0.0, to = 1.0) float alpha) {

  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
    return;
  }

  Window window = activity.getWindow();
  ViewGroup decorView = (ViewGroup) window.getDecorView();
  ViewGroup drawContent = (ViewGroup) drawerLayout.getChildAt(0);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(Color.TRANSPARENT);
    drawerLayout.setStatusBarBackgroundColor(statusBarColor);

    int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
    systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
    systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    window.getDecorView().setSystemUiVisibility(systemUiVisibility);
  } else {
    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  }

  setStatusBar(decorView, statusBarColor, true, true);
  setTranslucentView(decorView, alpha);

  drawerLayout.setFitsSystemWindows(false);
  drawContent.setFitsSystemWindows(true);
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawer.setFitsSystemWindows(false);
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:46,代码来源:SystemBarHelper.java

示例4: dispatchKeyEvent

import android.view.Window; //导入方法依赖的package包/类
/**
 * Called to process key events.  You can override this to intercept all
 * key events before they are dispatched to the window.  Be sure to call
 * this implementation for key events that should be handled normally.
 *
 * @param event The key event.
 *
 * @return boolean Return true if this event was consumed.
 */
public boolean dispatchKeyEvent(KeyEvent event) {
    onUserInteraction();

    // Let action bars open menus in response to the menu key prioritized over
    // the window handling it
    final int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_MENU &&
            mActionBar != null && mActionBar.onMenuKeyEvent(event)) {
        return true;
    } else if (event.isCtrlPressed() &&
            event.getUnicodeChar(event.getMetaState() & ~KeyEvent.META_CTRL_MASK) == '<') {
        // Capture the Control-< and send focus to the ActionBar
        final int action = event.getAction();
        if (action == KeyEvent.ACTION_DOWN) {
            final ActionBar actionBar = getActionBar();
            if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) {
                mEatKeyUpEvent = true;
                return true;
            }
        } else if (action == KeyEvent.ACTION_UP && mEatKeyUpEvent) {
            mEatKeyUpEvent = false;
            return true;
        }
    }

    Window win = getWindow();
    if (win.superDispatchKeyEvent(event)) {
        return true;
    }
    View decor = mDecor;
    if (decor == null) decor = win.getDecorView();
    return event.dispatch(this, decor != null
            ? decor.getKeyDispatcherState() : null, this);
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:44,代码来源:a.java

示例5: tintStatusBar

import android.view.Window; //导入方法依赖的package包/类
public static void tintStatusBar(Activity activity, @ColorInt int statusBarColor, @FloatRange(from = 0.0, to = 1.0) float alpha) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            return;
        }
        Window window = activity.getWindow();
        ViewGroup decorView = (ViewGroup) window.getDecorView();
        ViewGroup contentView = (ViewGroup) window.getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
        View rootView = contentView.getChildAt(0);
        if (rootView != null && !ViewCompat.getFitsSystemWindows(rootView)) {
            ViewCompat.setFitsSystemWindows(rootView, true);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
//            window.setStatusBarColor(Color.TRANSPARENT);
            window.getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
            if (statusBarColor != COLOR_INVALID_VAL) {
                window.setStatusBarColor(statusBarColor);
            }
        } else {
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            setStatusBar(decorView, statusBarColor, true);
            setTranslucentView(decorView, alpha);
        }


    }
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:29,代码来源:Util.java

示例6: setStatusBarStyle

import android.view.Window; //导入方法依赖的package包/类
public static void setStatusBarStyle(BaseActivity activity, boolean isLight) {
    boolean isMIUI = setMIUIStatusBarStyle(activity, isLight);

    if (!isMIUI) {
        Window window = activity.getWindow();
        View decor = window.getDecorView();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isLight) {
            decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        } else {
            decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }
    }
}
 
开发者ID:nichbar,项目名称:Aequorea,代码行数:15,代码来源:DisplayUtils.java

示例7: onKey

import android.view.Window; //导入方法依赖的package包/类
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
    if (keyCode == 82 || keyCode == 4) {
        Window win;
        View decor;
        DispatcherState ds;
        if (event.getAction() == 0 && event.getRepeatCount() == 0) {
            win = this.mDialog.getWindow();
            if (win != null) {
                decor = win.getDecorView();
                if (decor != null) {
                    ds = decor.getKeyDispatcherState();
                    if (ds != null) {
                        ds.startTracking(event, this);
                        return true;
                    }
                }
            }
        } else if (event.getAction() == 1 && !event.isCanceled()) {
            win = this.mDialog.getWindow();
            if (win != null) {
                decor = win.getDecorView();
                if (decor != null) {
                    ds = decor.getKeyDispatcherState();
                    if (ds != null && ds.isTracking(event)) {
                        this.mMenu.close(true);
                        dialog.dismiss();
                        return true;
                    }
                }
            }
        }
    }
    return this.mMenu.performShortcut(keyCode, event, 0);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:35,代码来源:MenuDialogHelper.java

示例8: hasWindowFocus

import android.view.Window; //导入方法依赖的package包/类
/**
 * Returns true if this activity's <em>main</em> window currently has window focus.
 * Note that this is not the same as the view itself having focus.
 *
 * @return True if this activity's main window currently has window focus.
 *
 * @see #onWindowAttributesChanged(android.view.WindowManager.LayoutParams)
 */
public boolean hasWindowFocus() {
    Window w = getWindow();
    if (w != null) {
        View d = w.getDecorView();
        if (d != null) {
            return d.hasWindowFocus();
        }
    }
    return false;
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:19,代码来源:a.java

示例9: setDefaultStatusBarFont

import android.view.Window; //导入方法依赖的package包/类
private static void setDefaultStatusBarFont(Activity activity, boolean dark) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = activity.getWindow();
        View decorView = window.getDecorView();
        if (dark) {
            decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        } else {
            decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
    }
}
 
开发者ID:yanzhenjie,项目名称:Sofia,代码行数:12,代码来源:Utils.java

示例10: SystemBarTintManager

import android.view.Window; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19)
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus,
                android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            mNavBarAvailable = a.getBoolean(1, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:52,代码来源:SystemBarTintManager.java

示例11: SystemBarTintManager

import android.view.Window; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19)
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus,
                android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            //mNavBarAvailable = a.getBoolean(1, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:52,代码来源:SystemBarTintManager.java

示例12: SystemBarTintManager

import android.view.Window; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19)
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus, android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            mNavBarAvailable = a.getBoolean(1, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:51,代码来源:SystemBarTintManager.java

示例13: SystemBarTintManager

import android.view.Window; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19)
@SuppressWarnings("ResourceType")
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus,
                android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            mNavBarAvailable = a.getBoolean(1, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:dufangyu1990,项目名称:LeCatApp,代码行数:53,代码来源:SystemBarTintManager.java

示例14: SystemBarTintManager

import android.view.Window; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19) public SystemBarTintManager(Activity activity) {

  Window win = activity.getWindow();
  ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    // check theme attrs
    int[] attrs = {
        android.R.attr.windowTranslucentStatus, android.R.attr.windowTranslucentNavigation
    };
    TypedArray a = activity.obtainStyledAttributes(attrs);
    try {
      mStatusBarAvailable = a.getBoolean(0, false);
      mNavBarAvailable = a.getBoolean(1, false);
    } finally {
      a.recycle();
    }

    // check window flags
    WindowManager.LayoutParams winParams = win.getAttributes();
    int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
    if ((winParams.flags & bits) != 0) {
      mStatusBarAvailable = true;
    }
    bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
    if ((winParams.flags & bits) != 0) {
      mNavBarAvailable = true;
    }
  }

  mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
  // device might not have virtual navigation keys
  if (!mConfig.hasNavigtionBar()) {
    mNavBarAvailable = false;
  }

  if (mStatusBarAvailable) {
    setupStatusBarView(activity, decorViewGroup);
  }
  if (mNavBarAvailable) {
    setupNavBarView(activity, decorViewGroup);
  }
}
 
开发者ID:Lingzh0ng,项目名称:BrotherWeather,代码行数:51,代码来源:SystemBarTintManager.java


注:本文中的android.view.Window.getDecorView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。