2017-02-04 16 views
0

私はAppCompatを使用してAndroid携帯アプリをスタイリングしています。 それはここではAPI 23ステータスバーの色が 'colorPrimaryDark'の代わりに 'windowBackground'に変更されています

である6.0のAndroidを実行していることは、私のAndroidManifest.xmlである:ここでは

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="FeedingTime.FeedingTime" android:versionCode="1" android:versionName="1.0" android:installLocation="auto"> 
    <uses-sdk /> 
    <application android:icon="@drawable/Icon" android:label="Feeding Time" android:theme="@style/AppTheme"> 
    </application> 
</manifest> 

は私style.xmlです:ここでは

<style name="AppTheme" parent="Theme.AppCompat.Light"> 
    <item name="android:windowTranslucentStatus">true</item> 

    <item name="android:windowBackground">@color/background_color</item> 

    <item name="colorPrimary">#6497b1</item> 
    <item name="colorPrimaryDark">#005b96</item> 
    </style> 

アクティビティレイアウトのXMLです問題が存在する場所:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 
    <include 
     android:id="@+id/toolbarHistoryActivity" 
     layout="@layout/toolbar" /> 
    <ListView 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="4" 
     android:id="@+id/listViewHistory" /> 
    <Button 
     android:text="Clear History" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:id="@+id/btnClearHistory" /> 
</LinearLayout> 

私は問題が発生しています。ステータスバーの色は期待どおりに濃い青色に設定されていますが、ステータスバーが色を変える2番目のアクティビティを開くと、 'colorPrimaryDark'を使用しなくなりましたが、 'windowBackground'にある色の色がより暗くなります。

なぜですか?

+0

は同様にあなたのマニフェストファイルを投稿! – OBX

答えて

1

は、rootとしてCoordinatorlayoutを追加し、代わりにLinearlayout

<android.support.design.widget.CoordinatorLayout 
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" 
tools:context=".MainActivity" 
android:fitsSystemWindows="true"> 

android:fitsSystemWindows="true"

を使用します。また、programeticallyあなたActivityStatusBar色を設定することができます。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 
getWindow().setStatusBarColor(getResources().getColor(R.color.your_color)); //change color here 
} 
+0

私は、ルートを 'android.support.v4.widget.DrawerLayout'に変更しました。これで動作します。提案に感謝します。 –

関連する問題