本文整理汇总了Java中android.view.Window.setStatusBarColor方法的典型用法代码示例。如果您正苦于以下问题:Java Window.setStatusBarColor方法的具体用法?Java Window.setStatusBarColor怎么用?Java Window.setStatusBarColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.Window
的用法示例。
在下文中一共展示了Window.setStatusBarColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transparentStatusBar
import android.view.Window; //导入方法依赖的package包/类
/**
* 使statusbar透明
*
* */
protected void transparentStatusBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = 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_STABLE);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
}
}
示例2: TpSbNNbwFCImmerseMode
import android.view.Window; //导入方法依赖的package包/类
public TpSbNNbwFCImmerseMode(@NonNull Activity activity) {
mActivityRef = new SoftReference<>(activity);
Window window = activity.getWindow();
WindowUtils.clearWindowFlags(window, FLAG_TRANSLUCENT_STATUS);
WindowUtils.clearWindowFlags(window, FLAG_TRANSLUCENT_NAVIGATION);
WindowUtils.addWindowFlags(window, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.getDecorView().setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_STABLE | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
mCompatStatusBarView = setupContentViewAndStatusBarView(activity);
window.setStatusBarColor(Color.TRANSPARENT);
mCompatStatusBarView.setBackgroundColor(Color.TRANSPARENT);
}
示例3: initStatusBar
import android.view.Window; //导入方法依赖的package包/类
protected void initStatusBar(){
if (Build.VERSION.SDK_INT >= 21) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(ThemeUtils.getColorById(this, R.color.theme_color_primary));
ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(null, null, ThemeUtils.getThemeAttrColor(this, android.R.attr.colorPrimary));
setTaskDescription(description);
}
}
示例4: tintStatusBar
import android.view.Window; //导入方法依赖的package包/类
/**
* Android4.4以上的状态栏着色
*
* @param window 一般都是用于Activity的window,也可以是其他的例如Dialog,DialogFragment
* @param statusBarColor 状态栏颜色
* @param alpha 透明栏透明度[0.0-1.0]
*/
public static void tintStatusBar(Window window,
@ColorInt int statusBarColor,
@FloatRange(from = 0.0, to = 1.0) float alpha) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
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);
} else {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
ViewGroup decorView = (ViewGroup) window.getDecorView();
ViewGroup contentView = (ViewGroup) window.getDecorView()
.findViewById(Window.ID_ANDROID_CONTENT);
View rootView = contentView.getChildAt(0);
if (rootView != null) {
ViewCompat.setFitsSystemWindows(rootView, true);
}
setStatusBar(decorView, statusBarColor, true);
setTranslucentView(decorView, alpha);
}
示例5: immersiveStatusBar
import android.view.Window; //导入方法依赖的package包/类
/**
* Android4.4以上的沉浸式全屏模式
* 注:
* 1.删除fitsSystemWindows属性:Android5.0以上使用该方法如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性
* 或者调用forceFitsSystemWindows方法
* 2.不删除fitsSystemWindows属性:也可以区别处理,Android5.0以上使用自己的方式实现,不调用该方法
*
* @param window 一般都是用于Activity的window,也可以是其他的例如Dialog,DialogFragment
* @param alpha 透明栏透明度[0.0-1.0]
*/
public static void immersiveStatusBar(Window window,
@FloatRange(from = 0.0, to = 1.0) float alpha) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
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);
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);
}
ViewGroup decorView = (ViewGroup) window.getDecorView();
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();
ViewCompat.setFitsSystemWindows(rootView, true);
lp.topMargin = -statusBarHeight;
rootView.setLayoutParams(lp);
}
setTranslucentView(decorView, alpha);
}
示例6: onPostCreate
import android.view.Window; //导入方法依赖的package包/类
@Override
public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onPostCreate(savedInstanceState);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(ThemeUtils.getColorById(this, R.color.theme_color_primary_dark));
ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(null, null,
ThemeUtils.getThemeAttrColor(this, android.R.attr.colorPrimary));
setTaskDescription(description);
}
}
示例7: setStatusColorDark
import android.view.Window; //导入方法依赖的package包/类
public void setStatusColorDark(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(getApplicationContext(), R.color.black));
}
}
示例8: setFullScreen
import android.view.Window; //导入方法依赖的package包/类
/**
* 设置全屏
*
* @param activity
*/
public static void setFullScreen(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
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
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
window.setNavigationBarColor(Color.TRANSPARENT);
}
}
示例9: enableLayoutFullScreen
import android.view.Window; //导入方法依赖的package包/类
/**
* 激活布局全屏, View 可以布局在 StatusBar 下面
*/
protected void enableLayoutFullScreen() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
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_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
}
示例10: changeStatusBarColor
import android.view.Window; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void changeStatusBarColor(int backgroundColor) {
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(backgroundColor);
}
示例11: setStatusBarColored
import android.view.Window; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setStatusBarColored() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}
}
示例12: setStatusBarColor
import android.view.Window; //导入方法依赖的package包/类
private void setStatusBarColor() {
Window window = this.getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(Color.BLACK);
}
}
示例13: setWindowBarColor
import android.view.Window; //导入方法依赖的package包/类
/**
* Set window bar color.
*
* @param statusColor status bar color.
* @param navigationColor navigation bar color.
*/
private void setWindowBarColor(@ColorInt int statusColor, @ColorInt int navigationColor) {
if (Build.VERSION.SDK_INT >= 21) {
final Window window = getWindow();
if (window != null) {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(statusColor);
window.setNavigationBarColor(navigationColor);
}
}
}
示例14: AndroidMStatusBarLightMode
import android.view.Window; //导入方法依赖的package包/类
private static boolean AndroidMStatusBarLightMode(Window window, boolean isDeepColor) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isDeepColor) {
//必须清除这个flag
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
window.setStatusBarColor(Color.TRANSPARENT);
return true;
}
return false;
}
示例15: onCreate
import android.view.Window; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(getResources().getColor(R.color.app_red));
}
setContentView(R.layout.activity_calendar);
initializeToolbar();
}