相关疑难解决方法(0)

如何更改android中的状态栏颜色

首先,它不是重复,如在如何更改Android状态栏的背景颜色

如何更改状态栏颜色,该颜色应与导航栏中的颜色相同.

我希望状态栏颜色与导航栏颜色相同

在此输入图像描述

android statusbar android-notifications android-navigation

371
推荐指数
17
解决办法
70万
查看次数

Android状态栏图标颜色

我想知道是否可以更改状态栏图标颜色(而不是状态栏颜色colorPrimaryDark) 在此输入图像描述 假设我想要这个状态栏:
<item name="colorPrimaryDark">@android:color/white</item>

和黑色的图标,这可能吗?

谢谢.

编辑:

M开发人员预览中的新功能:windowLightStatusBar.在主题中翻转它会告诉系统使用深色前景,对浅色状态栏很有用.请注意,M预览似乎有一个错误,通知图标保持白色,而系统状态图标正确地变为半透明黑色.

来自:Roman Nurik的 Google+ 帖子 在此输入图像描述

android android-styles android-5.0-lollipop android-statusbar

107
推荐指数
7
解决办法
9万
查看次数

状态栏变为白色,并且不显示其背后的内容

我在Marshmallow上尝试AppCompat.我希望有一个透明的状态栏,但它会变成白色.我已经尝试了几个解决方案,但它们对我不起作用(透明状态栏不能使用windowTranslucentNavigation ="false",Lollipop:绘制后面的statusBar,其颜色设置为透明).这是相关的代码.

我的styles.xml

<style name="Bacon" parent="Theme.Bacon"/>

<style name="Theme.Bacon" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/theme_primary</item>
    <item name="colorPrimaryDark">@color/theme_primary_dark</item>
    <item name="colorAccent">@color/theme_accent</item>
    <item name="windowActionBar">false</item>
    <item name="windowActionBarOverlay">true</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowBackground">@color/background_material_light</item>  
</style>

<style name="Theme.Bacon.Detail" parent="Bacon"/>
Run Code Online (Sandbox Code Playgroud)

V21

<style name="Bacon" parent="Theme.Bacon">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

<style name="Theme.Bacon.Detail" parent="Bacon">
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

活动

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true" />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

分段

<android.support.design.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:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="192dp"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginBottom="32dp"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed" …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat android-support-library androiddesignsupport android-6.0-marshmallow

84
推荐指数
12
解决办法
6万
查看次数

当primaryDark为白色时更改状态栏文本颜色

我正在尝试重现Google日历应用程序的行为: 在此输入图像描述

但我还没有找到改变状态文本颜色的方法.如果我将colorPrimaryDark设置为白色,我无法看到图标既不是状态栏的文本也不是因为它们的颜色也是白色.

有没有办法改变状态栏文字颜色?

提前致谢

android android-styles android-statusbar

50
推荐指数
5
解决办法
4万
查看次数

在 Android 11 (API 30) 中以编程方式更改状态栏文本颜色

我目前可以使用基本活动中的以下内容将状态栏文本颜色从浅色更新为深色:

private fun toggleStatusBarTextColor(light: Boolean) {
    // clear any existing flags
    window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
    if(light) {
        window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
    } else {
        window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
    }
}
Run Code Online (Sandbox Code Playgroud)

systemUiVisibility 现在在 API 30 上显示已弃用,尽管已弃用的方法暂时仍将起作用,但我更愿意用更新的方法替换它们来实现此目的。我读到我们现在应该使用 WindowInsetsController 函数,但尚不清楚如何从文档中完成此操作。有人能指出我正确的方向吗?

java android android-theme kotlin android-statusbar

6
推荐指数
2
解决办法
1万
查看次数

如何更改 Android 中的状态栏图标颜色?

我想将状态栏图标颜色从白色更改为黑色。我尝试下面的代码,但我做不到。请问你能帮帮我吗?

活动代码:

public static void setLightStatusBar(View view,Activity activity){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
        activity.getWindow().setStatusBarColor(Color.WHITE);
    }
}
Run Code Online (Sandbox Code Playgroud)

style.xml 代码:

<item name="android:windowLightStatusBar">true</item>
Run Code Online (Sandbox Code Playgroud)

icons android colors statusbar

4
推荐指数
1
解决办法
1万
查看次数