【问题标题】:How to make the statusbar black (default) in android?如何在android中使状态栏变黑(默认)?
【发布时间】:2015-12-02 19:36:48
【问题描述】:

我的一项活动在状态栏中突然改变了颜色。默认是黑色的,现在是透明的,为什么?

I've marked around the bar with a circle. By default this is black

我的 XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="centerInside"
    android:id="@+id/do2get"
    android:src="@drawable/loading"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="30dp" />

<ProgressBar
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:indeterminateTint="#00796b"
    android:id="@+id/progressBar"
    android:layout_below="@+id/do2get"
    android:layout_centerHorizontal="true"
    android:indeterminateTintMode="src_in"/>
</RelativeLayout>

【问题讨论】:

  • 在清单文件中检查活动的主题..
  • 我把它写成android:theme="@style/AppTheme.NoActionBar" &gt;,但我想从屏幕顶部开始(带有时钟和WIFI信号)

标签: android


【解决方案1】:

我认为这完全与您的活动主题有关。 首先检查这个链接:

How to change the status bar color in android

How to change the background color of android status bar

也许你的基础主题有属性 "android:windowTranslucentStatus" = true 或 "colorPrimaryDark = @android:color/transparent" 等等。所以你需要创建一个新的风格,比如:

<style name="YourActivityTheme" parent="BaseAppTheme">
    <item name="android:windowTranslucentStatus">false</item>
    <item name="android:statusBarColor">@android:color/black</item>
</style>

然后将此样式设置为 AndroidManifest 中的当前活动主题:

<aplication
        ....... >
            .......    

         <activity
                android:name=".chapters.home.YourNiceActivity"
                android:theme="@style/YourActivityTheme">
                <intent-filter>
                   ...
                </intent-filter>
        </activity>

    .....
</application>

【讨论】:

  • 谢谢 :) 我刚刚将 android:statusBarColor 从透明更改为黑色
猜你喜欢
  • 1970-01-01
  • 2015-01-15
  • 2014-02-05
  • 2011-06-18
  • 1970-01-01
  • 2015-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多