繁体   English   中英

Android 通知栏颜色随文字更改为白色

[英]Android Notification Bar Color Changed to White along with the Text

这是选项卡的简单布局。 当我切换到此页面时,Android 通知面板变为白色。 我尝试更改 colors 并检查 Android 通知面板,但它仍然是白色的,文本也是白色的。 它的白色背景+白色文本,因此用户可以看到任何通知。

这可能是什么原因造成的?

截屏

    <?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Tabb">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/primaryDark"
        android:theme="@style/AppTheme.AppBarOverlay"
        android:elevation="3dp">


        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:minHeight="?actionBarSize"
            android:text="Bookings"
            android:layout_marginLeft="20dp"
            android:textColor="@color/white"
            android:elevation="5dp"
            android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title" />

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/grey"
            android:elevation="5dp"/>
    </com.google.android.material.appbar.AppBarLayout>

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/view_pager1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="?attr/actionBarSize"
        android:layout_marginTop="?attr/actionBarSize"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:itemBackground="@color/grey"
        app:itemIconTint="@drawable/selector"
        app:menu="@menu/menu_navigation"
        app:labelVisibilityMode="unlabeled"/>
</RelativeLayout>

检查你的造型..

可能存在以下问题:

android:background="@color/primaryDark"
android:theme="@style/AppTheme.AppBarOverlay"

将此添加到您的 color.xml 中:

     <color name="colorPrimaryDark">#000000</color> //add your hex code color for notification bar

或用于 java

        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.colorprimarydark));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM