Ver Fonte

解决CoordinatorLayout折叠之后在状态栏还显示的问题,因为状态栏颜色为半透明色,换不透明色即可

詹子聪 há 6 anos atrás
pai
commit
c045f76524

+ 4 - 3
app/src/main/AndroidManifest.xml

@@ -15,7 +15,8 @@
         <activity
             android:name=".ui.TabActivity"
             android:label="@string/app_name"
-            android:screenOrientation="portrait">
+            android:screenOrientation="portrait"
+            android:theme="@style/SplashTheme">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
@@ -31,13 +32,13 @@
         <activity
             android:name=".ui.mine.login.LoginActivity"
             android:screenOrientation="portrait"
-            android:theme="@style/TextInputStyle" />
+            android:theme="@style/TextInputStyle"/>
 
         <activity
             android:name=".ui.mine.login.register.RegisterActivity"
             android:screenOrientation="portrait"
             android:theme="@style/TextInputStyle"
-            android:windowSoftInputMode="stateVisible|adjustResize" />
+            android:windowSoftInputMode="stateVisible|adjustResize"/>
 
         <activity
             android:name=".ui.mine.login.forget.ForgetActivity"

+ 3 - 1
app/src/main/res/layout/activity_tab.xml

@@ -2,7 +2,9 @@
 <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:background="@color/colorPrimary"
+    android:fitsSystemWindows="true">
 
     <com.google.android.material.appbar.AppBarLayout
         android:layout_width="match_parent"

+ 2 - 1
app/src/main/res/values/colors.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:tools="http://schemas.android.com/tools">
+<resources>
     <color name="colorPrimary">#fafafa</color>
     <color name="colorPrimaryDark">#fafafa</color>
     <color name="colorAccent">@color/green_logo</color>
@@ -14,6 +14,7 @@
     <color name="gray_disabled">#4DFFFFFF</color>
     <color name="gray_text">#222222</color>
     <color name="gray_bg_default">#F3F3F3</color>
+    <color name="gray_status_bar_2">#C8C8C8</color>
     <!-- 内容文字,正文 -->
     <color name="gray_text_s">#777777</color>
     <!-- 辅助文字,提示 -->

+ 8 - 3
app/src/main/res/values/styles.xml

@@ -6,11 +6,13 @@
         <item name="colorPrimary">@color/colorPrimary</item>
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
         <item name="colorAccent">@color/colorAccent</item>
+    </style>
+
+    <style name="SplashTheme" parent="AppTheme">
         <item name="windowActionBar">false</item>
         <item name="android:windowNoTitle">true</item>
 
-
-        <item name="android:statusBarColor">@color/white_transparent</item>
+        <item name="android:statusBarColor">@color/gray_status_bar</item>
         <item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
 
 
@@ -30,6 +32,9 @@
     <style name="BackTheme" parent="AppTheme">
         <!--改变下面这个颜色可以改变返回按钮的颜色-->
         <item name="android:textColorSecondary">@color/black_theme</item>
+
+        <item name="android:statusBarColor">@color/gray_status_bar</item>
+        <item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
     </style>
 
 
@@ -55,7 +60,7 @@
         <item name="colorAccent">@color/black_theme</item>
         <item name="windowActionBar">false</item>
         <item name="android:windowNoTitle">true</item>
-        <item name="android:statusBarColor">@color/white_transparent</item>
+        <item name="android:statusBarColor">@color/gray_status_bar</item>
         <item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
     </style>
 </resources>