简体   繁体   English

如何在Kitkat下的sdk版本中更改状态栏的颜色

[英]How to change the color of status bar in sdk version under kitkat

I want to make statusbar's color as the color of toolbar. 我想将状态栏的颜色设为工具栏的颜色。 But i don't known how to do it in android sdk version under kitkat. 但是我不知道如何在kitkat下的android sdk版本中做到这一点。 This is my toolbar layout: 这是我的工具栏布局:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/material_light_blue"
    android:minHeight="?attr/actionBarSize"
    android:layout_gravity="center_horizontal">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageButton
            android:id="@+id/info_button"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@null"
            android:src="@drawable/info"/>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center_vertical">

            <TextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="@dimen/text_title_size"
                android:textColor="@color/white"
                android:layout_gravity="center"
                android:text="@string/app_name" />

            <TextView
                android:id="@+id/toolbar_subtitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="@dimen/text_sub_title_size"
                android:textColor="@color/white"
                android:layout_gravity="center"/>
        </LinearLayout>
    </LinearLayout>
</android.support.v7.widget.Toolbar>

It is my app theme: @color/white @color/white @dimen/text_sub_title_size 这是我的应用程序主题:@ color / white @ color / white @ dimen / text_sub_title_size

Many thanks in advance! 提前谢谢了!

You can't. 你不能 Simple as that. 就那么简单。 KitKat is the first version that supported transparency of any kind in the status bar. KitKat是第一个在状态栏中支持任何类型透明度的版本。

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

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