2016-08-19 76 views
1

我是基於Marshmallow源代碼自定義設置應用程序;例如:動作條的顏色,狀態欄,EditTextView,對話框按鈕等。 在閱讀材料設計的嚮導之後,知道colorAccent的修改能遇到我。 所以,我做如下:自定義colorAccent不能在設置應用程序中工作

<style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Settings" /> 
<style name="Theme.Settings" parent="Theme.SettingsBase"> 
    <item name="android:colorAccent">@color/red</item> 
</style> 

不幸的是,它不能正常工作,它們的顏色仍然是深青色。

的源代碼: http://androidxref.com/6.0.0_r1/xref/packages/apps/Settings/res/values/themes.xml

+0

'@ color/red'的值是多少? –

+0

#F00 user6548319

+0

我會盡快調查。 –

回答

0

請檢查是否有主題強制操作首先你申請你自己的風格之後,尤其是來電applyStyle/setTheme的。

colorPrimaryDark不能工作,雖然Theme.Settings已設置windowDrawsSystemBarBackgrounds因爲在PhoneWindow.java和ActivityManager.java下面的代碼:

// PhoneWindow.java 
protected ViewGroup generateLayout(DecorView decor) { 
    // Non-floating windows on high end devices must put up decor beneath the system bars and 
    // therefore must know about visibility changes of those. 
    if (!mIsFloating && ActivityManager.isHighEndGfx()) { // Shield off this flag if isFloating or lowEndGfx 
     if (!targetPreL && a.getBoolean(
       R.styleable.Window_windowDrawsSystemBarBackgrounds, 
       false)) { 
      setFlags(FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, 
        FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS & ~getForcedWindowFlags()); 
     } 
    } 
    ... 
} 


private WindowInsets updateColorViews(WindowInsets insets, boolean animate) { 

    if (!mIsFloating && ActivityManager.isHighEndGfx()) { 

     ... 
    } 

    ... 
} 

// ActivityManager.java 
static public boolean isHighEndGfx() { 
     return !isLowRamDeviceStatic() && 
       !Resources.getSystem().getBoolean(com.android.internal.R.bool.config_avoidGfxAccel); 
    } 

    /** @hide */ 
public static boolean isLowRamDeviceStatic() { 
    return "true".equals(SystemProperties.get("ro.config.low_ram", "false")); 
} 

我只是改變其不檢查ロPhoneWindow的政策。 config.low_ram屬性來快速實現我的預期。

相關問題