本文整理汇总了Java中android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR属性的典型用法代码示例。如果您正苦于以下问题:Java View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR属性的具体用法?Java View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR怎么用?Java View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.View
的用法示例。
在下文中一共展示了View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processM
@TargetApi(Build.VERSION_CODES.M)
private void processM() {
if (current < Build.VERSION_CODES.M) {
return;
}
int flag = window.getDecorView().getSystemUiVisibility();
if (lightStatusBar) {
/**
* 改变字体颜色
* see {@link <a href="https://developer.android.com/reference/android/R.attr.html#windowLightStatusBar"></a>}
*/
flag |= (WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
| View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
window.setStatusBarColor(Color.TRANSPARENT);
}
if (transparentStatusBar) {
flag |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
window.setStatusBarColor(Color.TRANSPARENT);
}
if (transparentNavigationbar) {
flag |= (View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
window.setNavigationBarColor(Color.TRANSPARENT);
}
window.getDecorView().setSystemUiVisibility(flag);
}
示例2: activateLightStatusBar
/**
* Sets the status bar to be light or not. Light status bar means dark icons.
* @param activate if true, make sure the status bar is light, otherwise base on wallpaper.
*/
public void activateLightStatusBar(boolean activate) {
boolean lightStatusBar = activate || (FeatureFlags.LIGHT_STATUS_BAR
&& mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX,
ExtractedColors.DEFAULT_DARK) == ExtractedColors.DEFAULT_LIGHT);
int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility();
int newSystemUiFlags = oldSystemUiFlags;
if (lightStatusBar) {
newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
} else {
newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
if (newSystemUiFlags != oldSystemUiFlags) {
getWindow().getDecorView().setSystemUiVisibility(newSystemUiFlags);
}
}
示例3: activateLightSystemBars
/**
* Sets the status and/or nav bar to be light or not. Light status bar means dark icons.
* @param isLight make sure the system bar is light.
* @param statusBar if true, make the status bar theme match the isLight param.
* @param navBar if true, make the nav bar theme match the isLight param.
*/
@TargetApi(23)
public void activateLightSystemBars(boolean isLight, boolean statusBar, boolean navBar) {
int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility();
int newSystemUiFlags = oldSystemUiFlags;
if (isLight) {
if (statusBar) {
newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
if (navBar && AndroidVersion.isAtLeastOreo()) {
newSystemUiFlags |= SYSTEM_UI_FLAG_LIGHT_NAV_BAR;
}
} else {
if (statusBar) {
newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
if (navBar && AndroidVersion.isAtLeastOreo()) {
newSystemUiFlags &= ~(SYSTEM_UI_FLAG_LIGHT_NAV_BAR);
}
}
if (newSystemUiFlags != oldSystemUiFlags) {
getWindow().getDecorView().setSystemUiVisibility(newSystemUiFlags);
}
}
示例4: setOPPOStatusBar
/**
* OPPO低版本系统(处理白色状态栏黑色字体兼容问题)
* 详细问题请参照OPPO开放平台:https://open.oppomobile.com/wiki/index#id=73494
* @param darkMode
* @param activity
*/
public void setOPPOStatusBar(boolean darkMode,Activity activity) {
final int SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT = 0x00000010;
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
int vis = window.getDecorView().getSystemUiVisibility();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (darkMode) {
vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
} else {
vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES. KITKAT) {
if (darkMode) {
vis &= ~SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
} else {
vis |= SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
}
}
window.getDecorView().setSystemUiVisibility(vis);
}
示例5: onItemClick
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (Item.values()[position]) {
case 默认主题:
mToolbar.setBackgroundResource(android.R.color.white);
mToolbar.setTitleTextColor(0xffbbbbbb);
mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_gray_24dp);
mRefreshLayout.setPrimaryColors(0xfff0f0f0, 0xffffffff);
if (Build.VERSION.SDK_INT >= 21) {
getWindow().setStatusBarColor(0xfff0f0f0);
}
if (Build.VERSION.SDK_INT >= 23) {
Window window = getWindow();
int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
window.getDecorView().setSystemUiVisibility(systemUiVisibility);
}
break;
case 蓝色主题:
setThemeColor(R.color.colorPrimary, R.color.colorPrimaryDark);
break;
case 绿色主题:
setThemeColor(android.R.color.holo_green_light, android.R.color.holo_green_dark);
break;
case 红色主题:
setThemeColor(android.R.color.holo_red_light, android.R.color.holo_red_dark);
break;
case 橙色主题:
setThemeColor(android.R.color.holo_orange_light, android.R.color.holo_orange_dark);
break;
}
mRefreshLayout.autoRefresh();
}
示例6: setThemeColor
private void setThemeColor(int colorPrimary, int colorPrimaryDark) {
mToolbar.setBackgroundResource(colorPrimary);
mToolbar.setTitleTextColor(ContextCompat.getColor(this, android.R.color.white));
mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white);
if (Build.VERSION.SDK_INT >= 21) {
getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark));
}
if (Build.VERSION.SDK_INT >= 23) {
Window window = getWindow();
int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
window.getDecorView().setSystemUiVisibility(systemUiVisibility);
}
}
示例7: darkModeForM
/** android 6.0设置字体颜色 */
@RequiresApi(Build.VERSION_CODES.M)
private static void darkModeForM(Window window, boolean dark) {
// window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// window.setStatusBarColor(Color.TRANSPARENT);
int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
if (dark) {
systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
} else {
systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
window.getDecorView().setSystemUiVisibility(systemUiVisibility);
}
示例8: setWindowLightStatusBar
public static void setWindowLightStatusBar(Activity activity, Boolean lightStatusBar) {
Window window = activity.getWindow();
View decor = window.getDecorView();
//取消设置透明状态栏,使 ContentView 内容不再覆盖状态栏
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
int ui = decor.getSystemUiVisibility();
if (lightStatusBar) {
ui |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
} else {
ui &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
decor.setSystemUiVisibility(ui);
}
示例9: setStatusBarDarkModeForM
/**
* android 6.0设置字体颜色
*/
@TargetApi(Build.VERSION_CODES.M)
public static void setStatusBarDarkModeForM(Window window) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
window.getDecorView().setSystemUiVisibility(systemUiVisibility);
}
示例10: Android6SetStatusBarLightMode
/**
* 设置状态栏字体图标为深色,Android 6
*
* @param window 需要设置的窗口
* @param light 是否把状态栏字体及图标颜色设置为深色
* @return boolean 成功执行返回true
*/
@TargetApi(23)
private static boolean Android6SetStatusBarLightMode(Window window, boolean light) {
View decorView = window.getDecorView();
int systemUi = light ? View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR : View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
systemUi = changeStatusBarModeRetainFlag(window, systemUi);
decorView.setSystemUiVisibility(systemUi);
return true;
}
示例11: clearLightStatusBar
public static void clearLightStatusBar(@NonNull View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int flags = view.getSystemUiVisibility();
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
view.setSystemUiVisibility(flags);
}
}
示例12: setLightStatusBar
public static void setLightStatusBar(View view, Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
View decor = activity.getWindow().getDecorView();
oldStatusBarFlags = decor.getSystemUiVisibility();
int flags = view.getSystemUiVisibility();
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
view.setSystemUiVisibility(flags);
activity.getWindow().setStatusBarColor(Color.WHITE);
}
}
示例13: setLightStatusBar
public static void setLightStatusBar(@NonNull View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int flags = view.getSystemUiVisibility();
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
view.setSystemUiVisibility(flags);
}
}
示例14: enableLightStatusBar
public static void enableLightStatusBar(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
View view = activity.getWindow().getDecorView();
int flags = view.getSystemUiVisibility();
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
view.setSystemUiVisibility(flags);
}
}
示例15: clearLightStatusBar
public static void clearLightStatusBar(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
View view = activity.getWindow().getDecorView();
int flags = view.getSystemUiVisibility();
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
view.setSystemUiVisibility(flags);
}
}