2014-12-07 30 views
14

的Android 5.0的指引,導航欄似乎可定製: http://www.google.com/design/spec/layout/structure.html#structure-system-bars如何改變系統導航欄的顏色

如何更改導航欄的顏色? 我想用白色的款式。

截圖: enter image description here enter image description here enter image description here enter image description here


編輯:在我的資源,我測試的樣式:

<item name="android:navigationBarColor" tools:targetApi="21">@android:color/white</item> 

但按鍵是白色的。我想要與第二張圖像相同的渲染器。

enter image description here

+0

Downvote,你能發展嗎? – alex 2014-12-10 15:52:05

+1

也許問題已經演變爲一個不同的問題:我如何定製導航欄按鈕的顏色? – 2015-12-09 15:07:01

回答

5

導航欄不應該是彩色的

當你自定義導航欄和狀態欄,要麼使他們既透明或者只修改狀態欄。在所有其他情況下,導航欄應保持黑色。

(來源https://developer.android.com/training/material/theme.html

但是,你可以使用這個庫來實現你想要的:) https://github.com/jgilfelt/SystemBarTint

+1

感謝您的幫助,我使用屬性「android:navigationBarColor」編輯了我的問題,但我不想使用庫。 – alex 2014-12-07 22:44:21

10

活動使用此。

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
     getWindow().setNavigationBarColor(getResources().getColor(R.color.green)); 
    } 
0

在V21 /風格

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="android:windowDrawsSystemBarBackgrounds">true</item> 
    <item name="android:statusBarColor">@android:color/transparent</item> 
    ***<item name="android:navigationBarColor">@color/colorPrimaryDark</item>*** 
</style> 

2

從API 27起加入本林樂,現在可以使用導航欄的光風格:

<item name="android:navigationBarColor">@android:color/white</item> 
<item name="android:windowLightNavigationBar">true</item> 

documentation

windowLightNavigationBar

如果設置,導航條將被繪製爲使得它是具有光導航欄背景兼容。

對於此生效,該窗口必須繪製系統欄 背景與windowDrawsSystemBarBackgrounds且不得被請求的導航欄 與 windowTranslucentNavigation是半透明的。對應於裝飾視圖上的設置 SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR。