com.readystatesoftware.systembartint.SystemBarTintManager Java Examples
The following examples show how to use
com.readystatesoftware.systembartint.SystemBarTintManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseActivity.java From bleYan with GNU General Public License v2.0 | 6 votes |
@TargetApi(19) public void setTranslucentStatus(Activity activity, boolean on) { if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { Window win = activity.getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); SystemBarTintManager tintManager = new SystemBarTintManager(activity); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(false); tintManager.setStatusBarTintColor(activity.getResources().getColor(R.color.colorPrimary)); //tintManager.setNavigationBarTintColor(activity.getResources().getColor(R.color.colorPrimary)); // tintManager.setStatusBarTintResource(R.color.colorPrimary); } }
Example #2
Source File: MainActivity.java From SpinningTabStrip with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.inject(this); setSupportActionBar(toolbar); // create our manager instance after the content view is set mTintManager = new SystemBarTintManager(this); // enable status bar tint mTintManager.setStatusBarTintEnabled(true); adapter = new MyPagerAdapter(getSupportFragmentManager()); pager.setAdapter(adapter); tabs.setViewPager(pager); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources() .getDisplayMetrics()); pager.setPageMargin(pageMargin); changeColor(getResources().getColor(R.color.green)); tabs.setOnTabReselectedListener(new SpinningTabStrip.OnTabReselectedListener() { @Override public void onTabReselected(int position) { Toast.makeText(MainActivity.this, "Tab reselected: " + position, Toast.LENGTH_SHORT).show(); } }); }
Example #3
Source File: BaseActivity.java From Sky31Radio with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Timber.i("onCreate"); AVAnalytics.trackAppOpened(getIntent()); setContentView(provideContentViewId()); ButterKnife.inject(this); if(toolbar!=null){ setSupportActionBar(toolbar); } if(!TextUtils.isEmpty(NavUtils.getParentActivityName(this))){ getSupportActionBar().setDisplayHomeAsUpEnabled(true); } if(Build.VERSION.SDK_INT <= 19){ tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(true); tintManager.setStatusBarTintColor(getResources().getColor(R.color.primary_dark)); } }
Example #4
Source File: ThreeActivity.java From ImmersiveStatusBar with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_three); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //透明状态栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //透明导航栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); SystemBarTintManager tintManager = new SystemBarTintManager(this); // 激活状态栏 tintManager.setStatusBarTintEnabled(true); // enable navigation bar tint 激活导航栏 tintManager.setNavigationBarTintEnabled(true); //设置系统栏设置颜色 //tintManager.setTintColor(R.color.red); //给状态栏设置颜色 tintManager.setStatusBarTintResource(R.color.mask_tags_1); //Apply the specified drawable or color resource to the system navigation bar. //给导航栏设置资源 tintManager.setNavigationBarTintResource(R.color.mask_tags_1); } }
Example #5
Source File: SomeActivity.java From something.apk with MIT License | 6 votes |
private void configureActionbar(){ ActionBar bar = getActionBar(); bar.setHomeButtonEnabled(true); bar.setDisplayShowHomeEnabled(false); tint = new SystemBarTintManager(this); TypedValue tintColor = new TypedValue(); if(getTheme().resolveAttribute(R.attr.statusBarBackground, tintColor, true)){ tint.setStatusBarTintEnabled(true); tint.setTintColor(tintColor.data); defaultActionbarColor = tintColor.data; currentActionbarColor = tintColor.data; }else{ tint.setStatusBarTintEnabled(false); } TypedValue actionbarBackground = new TypedValue(); if(getTheme().resolveAttribute(R.attr.actionbarBackgroundLayerList, actionbarBackground, false)){ actionbarBackgroundList = (LayerDrawable) getResources().getDrawable(actionbarBackground.data); actionbarBackgroundList.mutate(); actionbarColor = (ColorDrawable) actionbarBackgroundList.findDrawableByLayerId(R.id.actionbar_background_color); actionbarColor.mutate(); bar.setBackgroundDrawable(actionbarBackgroundList); } }
Example #6
Source File: MainActivity.java From TigerVideo with Apache License 2.0 | 6 votes |
@TargetApi(19) private void setTranslucentStatus(boolean on) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); } SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintColor(getResources().getColor(R.color.colorPrimary)); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(false); }
Example #7
Source File: SystemBarUtils.java From likequanmintv with Apache License 2.0 | 6 votes |
public static void setStatusBarTranslate(AppCompatActivity mActivity, int resId){ SystemBarTintManager tintManager = new SystemBarTintManager(mActivity); if (resId== R.color.transparent){ // enable status bar tint tintManager.setStatusBarTintEnabled(false); // enable navigation bar tint tintManager.setNavigationBarTintEnabled(false); //noinspection deprecation }else { // enable status bar tint tintManager.setStatusBarTintEnabled(true); // enable navigation bar tint tintManager.setNavigationBarTintEnabled(true); // enable navigation bar tint } tintManager.setStatusBarTintColor(mActivity.getResources().getColor(resId)); }
Example #8
Source File: PagerSlidingTabStripActivity.java From UltimateAndroid with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pager_sliding_tab_activity_main); ButterKnife.inject(this); setSupportActionBar(toolbar); // create our manager instance after the content view is set mTintManager = new SystemBarTintManager(this); // enable status bar tint mTintManager.setStatusBarTintEnabled(true); adapter = new MyPagerAdapter(getSupportFragmentManager()); pager.setAdapter(adapter); tabs.setViewPager(pager); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources() .getDisplayMetrics()); pager.setPageMargin(pageMargin); changeColor(getResources().getColor(R.color.Green)); }
Example #9
Source File: HomeActivity.java From bleYan with GNU General Public License v2.0 | 6 votes |
@TargetApi(19) public void setTranslucentStatus(Activity activity, boolean on) { if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { Window win = activity.getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); SystemBarTintManager tintManager = new SystemBarTintManager(activity); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(false); tintManager.setStatusBarTintColor(activity.getResources().getColor(R.color.colorPrimary)); //tintManager.setNavigationBarTintColor(activity.getResources().getColor(R.color.colorPrimary)); // tintManager.setStatusBarTintResource(R.color.colorPrimary); } }
Example #10
Source File: ColorActivity.java From SystemBarTint with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_color); mTintManager = new SystemBarTintManager(this); mTintManager.setStatusBarTintEnabled(true); mTintManager.setNavigationBarTintEnabled(true); mColorPicker = (ColorPicker) findViewById(R.id.color_picker); applySelectedColor(); mButton = (Button) findViewById(R.id.button); mButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { applySelectedColor(); } }); }
Example #11
Source File: StatusBarUtil.java From FimiX8-RE with MIT License | 5 votes |
public static void setStatusBarColor(Activity activity, int colorId) { if (VERSION.SDK_INT >= 21) { Window window = activity.getWindow(); window.addFlags(NTLMConstants.FLAG_UNIDENTIFIED_9); window.getDecorView().setSystemUiVisibility(FimiAppContext.UI_HEIGHT); } else if (VERSION.SDK_INT >= 19) { transparencyBar(activity); SystemBarTintManager tintManager = new SystemBarTintManager(activity); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(colorId); } }
Example #12
Source File: BasePlayerActivity.java From SimplifyReader with Apache License 2.0 | 5 votes |
/** * use SytemBarTintManager * * @param tintDrawable */ protected void setSystemBarTintDrawable(Drawable tintDrawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { SystemBarTintManager mTintManager = new SystemBarTintManager(this); if (tintDrawable != null) { mTintManager.setStatusBarTintEnabled(true); mTintManager.setTintDrawable(tintDrawable); } else { mTintManager.setStatusBarTintEnabled(false); mTintManager.setTintDrawable(null); } } }
Example #13
Source File: BaseActivity.java From githot with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(provideContentViewId()); if (Build.VERSION.SDK_INT <= 19) { tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(true); tintManager.setStatusBarTintColor(getResources().getColor(R.color.primary_dark)); } }
Example #14
Source File: BaseFragmentActivity.java From SimplifyReader with Apache License 2.0 | 5 votes |
/** * use SytemBarTintManager * * @param tintDrawable */ protected void setSystemBarTintDrawable(Drawable tintDrawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { SystemBarTintManager mTintManager = new SystemBarTintManager(this); if (tintDrawable != null) { mTintManager.setStatusBarTintEnabled(true); mTintManager.setTintDrawable(tintDrawable); } else { mTintManager.setStatusBarTintEnabled(false); mTintManager.setTintDrawable(null); } } }
Example #15
Source File: ConfigurationActivity.java From Noyze with Apache License 2.0 | 5 votes |
public static void setupActionBar(Activity activity) { // Tint the status bar, if available. SystemBarTintManager tintManager = new SystemBarTintManager(activity); tintManager.setStatusBarTintEnabled(true); tintManager.setTintColor(activity.getResources().getColor(R.color.action_bar_dark)); ActionBar actionBar = activity.getActionBar(); if (null != actionBar) { actionBar.setIcon(DateUtils.AppIcon()); actionBar.setDisplayHomeAsUpEnabled(!activity.isTaskRoot()); actionBar.setDisplayShowTitleEnabled(true); } }
Example #16
Source File: ListViewUtils.java From filemanager with MIT License | 5 votes |
/** * Add padding to listview to compensate for translucent navbar and system bar */ public static void addListViewPadding(AbsListView listView, Activity activity, boolean ignoreRightInset) { SystemBarTintManager systemBarTintManager = new SystemBarTintManager(activity); int headerHeight = systemBarTintManager.getConfig().getPixelInsetTop(true); int footerHeight = systemBarTintManager.getConfig().getPixelInsetBottom(); int paddingRight = systemBarTintManager.getConfig().getPixelInsetRight(); listView.setPadding(listView.getPaddingLeft(), headerHeight, ignoreRightInset ? listView.getPaddingRight() : paddingRight, footerHeight); }
Example #17
Source File: MainActivity.java From Netease with GNU General Public License v3.0 | 5 votes |
@TargetApi(19) private void initWindow() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintColor(getResources().getColor(R.color.tab_top_background)); tintManager.setStatusBarTintEnabled(true); } }
Example #18
Source File: NewsDisplayActivity.java From Netease with GNU General Public License v3.0 | 5 votes |
@TargetApi(19) private void initWindow() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintColor(getResources().getColor(R.color.tab_top_background)); tintManager.setStatusBarTintEnabled(true); } }
Example #19
Source File: MainActivity.java From mCalendar with Apache License 2.0 | 5 votes |
private void changeStatusBarColor(){ if (Build.VERSION.SDK_INT > 18){ Window window = getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(false); tintManager.setTintColor(getResources().getColor(R.color.colorPrimaryDark)); } }
Example #20
Source File: BaseActivity.java From AppPlus with MIT License | 5 votes |
/** * 为Android 4.4以上设备使用沉浸时效果 */ @TargetApi(Build.VERSION_CODES.KITKAT) private void setTintLayout() { mBarTintManager = new SystemBarTintManager(this); mBarTintManager.setStatusBarTintEnabled(true); mBarTintManager.setNavigationBarTintEnabled(true); mBarTintManager.setTintColor(Utils.getThemePrimaryColor(this)); }
Example #21
Source File: Utility.java From BlackLight with GNU General Public License v3.0 | 5 votes |
@TargetApi(19) public static void enableTint(Activity activity) { if (Build.VERSION.SDK_INT < 19) return; Window w = activity.getWindow(); WindowManager.LayoutParams p = w.getAttributes(); p.flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; w.setAttributes(p); SystemBarTintManager m = new SystemBarTintManager(activity); m.setStatusBarTintEnabled(true); m.setStatusBarTintResource(R.color.action_gray); }
Example #22
Source File: ConfigurationActivity.java From Noyze with Apache License 2.0 | 5 votes |
public static void setupActionBar(Activity activity) { // Tint the status bar, if available. SystemBarTintManager tintManager = new SystemBarTintManager(activity); tintManager.setStatusBarTintEnabled(true); tintManager.setTintColor(activity.getResources().getColor(R.color.action_bar_dark)); ActionBar actionBar = activity.getActionBar(); if (null != actionBar) { actionBar.setIcon(DateUtils.AppIcon()); actionBar.setDisplayHomeAsUpEnabled(!activity.isTaskRoot()); actionBar.setDisplayShowTitleEnabled(true); } }
Example #23
Source File: AboutActivity.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_about); // set indicator enable Toolbar mToolbar = findViewById(R.id.toolbar_actionbar); setSupportActionBar(mToolbar); final Drawable upArrow = getResources().getDrawable(R.drawable.ic_svg_back); if(getSupportActionBar() != null && upArrow != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); upArrow.setColorFilter(getResources().getColor(R.color.default_white), PorterDuff.Mode.SRC_ATOP); getSupportActionBar().setHomeAsUpIndicator(upArrow); } // change status bar color tint, and this require SDK16 if (Build.VERSION.SDK_INT >= 16 ) { // create our manager instance after the content view is set SystemBarTintManager tintManager = new SystemBarTintManager(this); // enable all tint tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(true); tintManager.setTintAlpha(0.15f); tintManager.setNavigationBarAlpha(0.0f); // set all color tintManager.setTintColor(getResources().getColor(android.R.color.black)); // set Navigation bar color if(Build.VERSION.SDK_INT >= 21) getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColor)); } // get version code TextView tvVersion = findViewById(R.id.app_version); tvVersion.setText(String.format(getResources().getString(R.string.about_version_template), BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)); }
Example #24
Source File: MatchActionBarActivity.java From SystemBarTint with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_match_actionbar); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(R.color.statusbar_bg); }
Example #25
Source File: DefaultActivity.java From SystemBarTint with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_default); SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(true); }
Example #26
Source File: SwipeBackAppCompatFragmentActivity.java From tup.dota2recipe with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // mHelper = new SwipeBackActivityHelper(this); // mHelper.onActivityCreate(); final SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(R.color.actionbar_bg); if (!Utils.hasSmartBar()) { tintManager.setNavigationBarTintEnabled(true); tintManager.setNavigationBarTintResource(R.color.statusbar_bg); } else { // Meizu 手机 // 设置状态栏图标文字为深色 Utils.setStatusBarDarkIcon(getWindow(), true); // 设置状态栏不透明 Utils.setImmersedWindow(getWindow(), false); final ActionBar bar = this.getSupportActionBar(); // 设置ActionBar顶栏背景 bar.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.ab_solid_tupdota2)); // 设置SmartBar背景 bar.setSplitBackgroundDrawable(this.getResources() .getDrawable(R.drawable.ab_bottom_solid_tupdota2)); } }
Example #27
Source File: LocalPlayerActivity.java From android with Apache License 2.0 | 5 votes |
private void updateControlersVisibility(boolean show) { if (show) { mControllers.setVisibility(View.VISIBLE); if (mFull == 1) { mActionBar.show(); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); if (AppUtils.hasKitKat()) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); tintManager = new SystemBarTintManager(LocalPlayerActivity.this); tintManager.setStatusBarTintColor(Color.parseColor("#5A33b5e5")); tintManager.setStatusBarTintEnabled(true); } mFull = 0; } } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); } mControllers.setVisibility(View.INVISIBLE); if (AppUtils.hasKitKat()) { tintManager.setStatusBarTintEnabled(false); } } }
Example #28
Source File: PreferencesActivity.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this); super.onCreate(savedInstanceState); setContentView(R.layout.prefsfrag); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable) getResources().getDrawable(R.drawable.ic_launcher)).getBitmap(), getColorPreference().getColor(ColorUsage.PRIMARY)); setTaskDescription(taskDescription); } setSupportActionBar(toolbar); getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE); getSupportActionBar().setBackgroundDrawable(getColorPreference().getDrawable(ColorUsage.PRIMARY)); if (SDK_INT == 20 || SDK_INT == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(getColorPreference().getColor(ColorUsage.PRIMARY)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences).getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (SDK_INT >= 21) { boolean colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(PreferenceUtils.getStatusColor(getColorPreference().getColorAsString(ColorUsage.PRIMARY))); if (colourednavigation) window.setNavigationBarColor(PreferenceUtils.getStatusColor(getColorPreference().getColorAsString(ColorUsage.PRIMARY))); } if (savedInstanceState != null){ selectedItem = savedInstanceState.getInt(KEY_CURRENT_FRAG_OPEN, 0); } selectItem(selectedItem); }
Example #29
Source File: RxBarTool.java From RxTools-master with Apache License 2.0 | 5 votes |
/** * 修改状态栏颜色,支持4.4以上版本 * * @param activity * @param colorId */ public static void setStatusBarColor(Activity activity, int colorId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); // window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(activity.getResources().getColor(colorId)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //使用SystemBarTint库使4.4版本状态栏变色,需要先将状态栏设置为透明 transparencyBar(activity); SystemBarTintManager tintManager = new SystemBarTintManager(activity); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(colorId); } }
Example #30
Source File: Util.java From polling-station-app with GNU Lesser General Public License v3.0 | 5 votes |
/** * Sets up a top-padding for the given app bar equal to the height of the status bar. * This increases the length of the app bar so it fits nicely below the status bar. * This method also sets the status bar transparency. * * @param appBar Toolbar to set padding to * @param activity Activity - current activity */ public static void setupAppBar(Toolbar appBar, Activity activity) { appBar.setPadding(0, getStatusBarHeight(activity.getResources()), 0, 0); SystemBarTintManager tintManager = new SystemBarTintManager(activity); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(true); tintManager.setTintColor(Color.parseColor("#10000000")); }