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


Java Window.setStatusBarColor方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:HStanN,项目名称:TakeRest,代码行数:19,代码来源:BaseActivity.java

示例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);
}
 
开发者ID:ls1110924,项目名称:ImmerseMode,代码行数:16,代码来源:TpSbNNbwFCImmerseMode.java

示例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);
    }
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:11,代码来源:RxBaseActivity.java

示例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);
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:35,代码来源:SystemBarHelper.java

示例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);
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:45,代码来源:SystemBarHelper.java

示例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);
  }
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:15,代码来源:RxBaseActivity.java

示例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));
    }
}
 
开发者ID:pooi,项目名称:Nearby,代码行数:8,代码来源:BaseActivity.java

示例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);
    }
}
 
开发者ID:SiberiaDante,项目名称:TitleLayout,代码行数:19,代码来源:ScreenUtil.java

示例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);
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:14,代码来源:StyleActivity.java

示例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);
}
 
开发者ID:msayan,项目名称:tutorial-view,代码行数:8,代码来源:TutorialActivity.java

示例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));
    }
}
 
开发者ID:AnhLeAit,项目名称:ContactLoader,代码行数:10,代码来源:BaseActivity.java

示例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);
    }
}
 
开发者ID:narenkukreja,项目名称:quire,代码行数:10,代码来源:WelcomeActivity.java

示例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);
        }
    }
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:17,代码来源:AlbumFolderDialog.java

示例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;
}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:13,代码来源:StatusBarUtils.java

示例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();
}
 
开发者ID:vipulyaara,项目名称:betterHotels,代码行数:14,代码来源:CalendarActivity.java


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