1)<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="windowActionBar">false</item> <item name="windowActionModeOverlay">true</item> <!-- Active thumb color & Active track color(30% transparency) --></style> <!--<item name="colorControlActivated">@color/colorPrimaryDark</item>--><style name="MyToolbarStyle" parent="ThemeOverlay.AppCompat.Light"> <item name="colorControlNormal">@color/color_drawer_textcolor</item> <item name="android:textColorSecondary">@color/color_drawer_textcolor</item> <item name="android:textColorPrimary">@color/color_drawer_textcolor</item> <item name="actionMenuTextColor">@android:color/white</item> <item name="android:textSize">@dimen/font_8dp</item> <item name="fontPath">@string/fonts_mont_bold</item> <item name="android:textAllCaps">false</item></style>
MainActivity
=============
@Overridepublic void onAttachedToWindow() { super.onAttachedToWindow(); setStatusBarImmersiveMode(HomeActivity.this, Color.TRANSPARENT);}public static void setStatusBarImmersiveMode(Activity activity, @ColorInt int color) { Window win = activity.getWindow(); // StatusBar if (Build.VERSION.SDK_INT >= 19) { // 19, 4.4, KITKAT win.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } if (Build.VERSION.SDK_INT >= 21) { // 21, 5.0, LOLLIPOP win.getAttributes().systemUiVisibility |= (View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); win.setStatusBarColor(color); } }in onCreate()//Code start for set status bar fully transperentpublic static void initStatusBar(Activity activity, View toolbar) { // Ensure `setStatusBarImmersiveMode()` if (Build.VERSION.SDK_INT >= 19) { // 19, 4.4, KITKAT // Ensure content view `fitsSystemWindows` is false. ViewGroup contentParent = (ViewGroup) activity.findViewById(android.R.id.content); View content = contentParent.getChildAt(0); // If using `DrawerLayout`, must ensure its subviews `fitsSystemWindows` are all false. // Because in some roms, such as MIUI, it will fits system windows for each subview. setFitsSystemWindows(content, false, true); // Add padding to hold the status bar place. clipToStatusBar(activity,toolbar); } }initStatusBar(ActMain.this, mBinding.commonToolbar.toolbar);
in manifest
==========
<application android:name="Application" android:allowBackup="true" android:icon="@mipmap/app_icon" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".activity.ActMain" android:configChanges="keyboardHidden|orientation" android:screenOrientation="portrait" android:theme="@style/NavigationStyle" android:windowSoftInputMode="stateHidden"></activity> <activity
No comments:
Post a Comment