本文整理了Java中android.view.Window.setNavigationBarColor()
方法的一些代码示例,展示了Window.setNavigationBarColor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.setNavigationBarColor()
方法的具体详情如下:
包路径:android.view.Window
类名称:Window
方法名:setNavigationBarColor
暂无
代码示例来源:origin: AppIntro/AppIntro
/**
* Allows the user to set the nav bar color of their app intro
*
* @param Color string form of color in 3 or 6 digit hex form (#ffffff)
*/
public void setNavBarColor(String Color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setNavigationBarColor(android.graphics.Color.parseColor(Color));
}
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
@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);
}
代码示例来源:origin: nickbutcher/plaid
@Override
public void onDrag(float elasticOffset, float elasticOffsetPixels,
float rawOffset, float rawOffsetPixels) {
if (elasticOffsetPixels > 0) {
// dragging downward, fade the status bar in proportion
activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(activity.getWindow()
.getStatusBarColor(), (int) ((1f - rawOffset) * statusBarAlpha)));
} else if (elasticOffsetPixels == 0) {
// reset
activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(
activity.getWindow().getStatusBarColor(), statusBarAlpha));
activity.getWindow().setNavigationBarColor(ColorUtils.modifyAlpha(
activity.getWindow().getNavigationBarColor(), navBarAlpha));
} else if (fadeNavBar) {
// dragging upward, fade the navigation bar in proportion
activity.getWindow().setNavigationBarColor(
ColorUtils.modifyAlpha(activity.getWindow().getNavigationBarColor(),
(int) ((1f - rawOffset) * navBarAlpha)));
}
}
代码示例来源:origin: wangdan/AisenWeiBo
public static void setStatusBar(Activity activity) {
// if (true) return;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);//| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// window.setStatusBarColor(Utils.resolveColor(activity, R.attr.theme_statusbar_color, Color.BLUE));
window.setStatusBarColor(Color.parseColor("#20000000"));
window.setNavigationBarColor(activity.getResources().getColor(ThemeUtils.themeColorArr[AppSettings.getThemeColor()][1]));
// window.setNavigationBarColor(Utils.resolveColor(activity, R.attr.theme_color, Color.BLUE));
// Window window = activity.getWindow();
// window.requestFeature(Window.FEATURE_NO_TITLE);
// window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
// | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
// window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// window.setStatusBarColor(Color.TRANSPARENT);
// window.setNavigationBarColor(Utils.resolveColor(activity, R.attr.theme_statusbar_color, Color.TRANSPARENT));
}
}
代码示例来源:origin: AppIntro/AppIntro
/**
* Allows the user to set the nav bar color of their app intro
*
* @param color int form of color. pass your color resource to here (R.color.your_color)
*/
public void setNavBarColor(@ColorRes int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, color));
}
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void showSystemUi() {
if (DEBUG) Log.d(TAG, "showSystemUi() called");
if (playerImpl != null && playerImpl.queueVisible) return;
final int visibility;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
} else {
visibility = View.STATUS_BAR_VISIBLE;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@ColorInt final int systenUiColor =
ActivityCompat.getColor(getApplicationContext(), R.color.video_overlay_color);
getWindow().setStatusBarColor(systenUiColor);
getWindow().setNavigationBarColor(systenUiColor);
}
getWindow().getDecorView().setSystemUiVisibility(visibility);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
代码示例来源:origin: xinghongfei/LookLook
@Override
public void onDrag(float elasticOffset, float elasticOffsetPixels,
float rawOffset, float rawOffsetPixels) {
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
if (elasticOffsetPixels > 0) {
// dragging downward, fade the status bar in proportion
activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(activity.getWindow()
.getStatusBarColor(), (int) ((1f - rawOffset) * statusBarAlpha)));
} else if (elasticOffsetPixels == 0) {
// reset
activity.getWindow().setStatusBarColor(ColorUtils.modifyAlpha(
activity.getWindow().getStatusBarColor(), statusBarAlpha));
activity.getWindow().setNavigationBarColor(ColorUtils.modifyAlpha(
activity.getWindow().getNavigationBarColor(), navBarAlpha));
} else if (fadeNavBar) {
// dragging upward, fade the navigation bar in proportion
activity.getWindow().setNavigationBarColor(
ColorUtils.modifyAlpha(activity.getWindow().getNavigationBarColor(),
(int) ((1f - rawOffset) * navBarAlpha)));
}
}
}
代码示例来源:origin: naman14/Timber
else window.setStatusBarColor(Color.BLACK);
if (Config.coloredNavigationBar(activity, key))
window.setNavigationBarColor(color);
else window.setNavigationBarColor(Color.BLACK);
applyTaskDescription(activity, key, color);
代码示例来源:origin: seven332/EhViewer
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(getThemeResId(Settings.getTheme()));
super.onCreate(savedInstanceState);
((EhApplication) getApplication()).registerActivity(this);
if (Analytics.isEnabled()) {
FirebaseAnalytics.getInstance(this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Settings.getApplyNavBarThemeColor()) {
getWindow().setNavigationBarColor(AttrResources.getAttrColor(this, R.attr.colorPrimaryDark));
}
}
代码示例来源:origin: iMeiji/Toutiao
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
if (getSupportActionBar() != null)
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(selectedColor));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// 状态栏上色
getWindow().setStatusBarColor(CircleView.shiftColorDown(selectedColor));
// 最近任务栏上色
ActivityManager.TaskDescription tDesc = new ActivityManager.TaskDescription(
getString(R.string.app_name),
BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_rect),
selectedColor);
setTaskDescription(tDesc);
// 导航栏上色
if (SettingUtil.getInstance().getNavBar()) {
getWindow().setNavigationBarColor(CircleView.shiftColorDown(selectedColor));
} else {
getWindow().setNavigationBarColor(Color.BLACK);
}
}
if (!dialog.isAccentMode()) {
SettingUtil.getInstance().setColor(selectedColor);
}
}
代码示例来源:origin: iMeiji/Toutiao
@Override
protected void onResume() {
super.onResume();
int color = SettingUtil.getInstance().getColor();
int drawable = Constant.ICONS_DRAWABLES[SettingUtil.getInstance().getCustomIconValue()];
if (getSupportActionBar() != null)
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(CircleView.shiftColorDown(color));
// 最近任务栏上色
ActivityManager.TaskDescription tDesc = new ActivityManager.TaskDescription(
getString(R.string.app_name),
BitmapFactory.decodeResource(getResources(), drawable),
color);
setTaskDescription(tDesc);
if (SettingUtil.getInstance().getNavBar()) {
getWindow().setNavigationBarColor(CircleView.shiftColorDown(color));
} else {
getWindow().setNavigationBarColor(Color.BLACK);
}
}
}
代码示例来源:origin: seven332/EhViewer
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(getThemeResId(Settings.getTheme()));
super.onCreate(savedInstanceState);
((EhApplication) getApplication()).registerActivity(this);
if (Analytics.isEnabled()) {
FirebaseAnalytics.getInstance(this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Settings.getApplyNavBarThemeColor()) {
getWindow().setNavigationBarColor(AttrResources.getAttrColor(this, R.attr.colorPrimaryDark));
}
}
代码示例来源:origin: iMeiji/Toutiao
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (SettingUtil.getInstance().getNavBar()) {
context.getWindow().setNavigationBarColor(CircleView.shiftColorDown(CircleView.shiftColorDown(color)));
} else {
context.getWindow().setNavigationBarColor(Color.BLACK);
代码示例来源:origin: jberkel/sms-backup-plus
@TargetApi(26)
private void setNavBarColor(@StyleRes final int themeId) {
final int navBarColor = getResources().getColor(
themeId == R.style.SMSBackupPlusTheme_Light ?
R.color.navigation_bar_light : R.color.navigation_bar_dark, null);
getWindow().setNavigationBarColor(navBarColor);
int visibility = getWindow().getDecorView().getSystemUiVisibility();
if (themeId == R.style.SMSBackupPlusTheme_Light) {
visibility |= SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
} else {
visibility &= ~(SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
getWindow().getDecorView().setSystemUiVisibility(visibility);
}
}
代码示例来源:origin: iielse/ImageWatcher
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
window.setNavigationBarColor(Color.TRANSPARENT);
isTranslucentStatus = true;
代码示例来源:origin: iielse/ImageWatcher
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
window.setNavigationBarColor(Color.TRANSPARENT);
isTranslucentStatus = true;
代码示例来源:origin: heinrichreimer/material-intro
getWindow().setNavigationBarColor(Color.TRANSPARENT);
} else if (position + positionOffset >= adapter.getCount() - 1) {
TypedValue typedValue = new TypedValue();
getWindow().setNavigationBarColor(navigationBarColor);
代码示例来源:origin: FolioReader/FolioReader-Android
color = typedArray.getColor(0, ContextCompat.getColor(this, R.color.white));
getWindow().setNavigationBarColor(color);
代码示例来源:origin: mingjunli/GithubApp
/**
* Allows the user to set the nav bar color of their app intro
*
* @param color int form of color. pass your color resource to here (R.color.your_color)
*/
public void setNavBarColor(@ColorRes int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, color));
}
}
代码示例来源:origin: malmstein/yahnac
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setSystemBarsColorOnLollipopAndLater() {
if (isAtLeastLollipop()) {
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
Resources resources = activity.getResources();
int statusBarColor = resources.getColor(configuration.getStatusBarColorResourceId());
int navigationBarColor = resources.getColor(configuration.getNavigationBarColorResourceId());
window.setStatusBarColor(statusBarColor);
window.setNavigationBarColor(navigationBarColor);
}
}
内容来源于网络,如有侵权,请联系作者删除!