2017-03-16 3 views
0

내 모든 환경 설정에 대해 평면 아이콘을 설정 했으므로 해당 아이콘의 색상을 전체적으로 변경하고 싶습니다.변경 방법 환경 설정 아이콘 색상을 전역으로 변경하는 방법 Android

아래 코드를 시도해도 도구 모음의 뒤로 단추 색이 변경됩니다.

환경 설정 아이콘 색조 만 전체적으로 변경되기를 원합니다. 미리 감사드립니다.

<style name="PreferencesTheme" parent="@style/AppTheme.NoActionBar"> 
    <item name="android:textColorPrimary">@color/primary_text</item> 
    <item name="android:textColorSecondary">@color/secondary_text</item> 
    <item name="android:colorAccent">@color/accent</item> 
    <item name="android:tint">@color/accent</item> 
</style> 
+0

동일한 이름의 색상을 사용하고 환경 설정 항목 배경색에 다른 색상을 설정했기 때문에 색상이 동 기적으로 바뀌고 ' @ color/your_color' –

답변

2

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> 

    <SwitchPreference 
     android:id="@+id/pref_toggle_alarm" 
     android:icon="@drawable/ic_pref_notifications" 
     android:key="key_toggle_alarm" 
     android:summaryOff="Alarm OFF" 
     android:summaryOn="Alarm ON" 
     android:title="Alarm" /> 


    <web.prefs.TimePrefs 
     android:id="@+id/pref_select_time" 
     android:icon="@drawable/ic_pref_time" 
     android:key="key_time" 
     android:summary="Set some time" 
     android:title="Select Time" /> 

    <MultiSelectListPreference 
     android:id="@+id/pref_select_week" 
     android:defaultValue="@array/week_array_values" 
     android:entries="@array/array_week_selection" 
     android:entryValues="@array/week_array_values" 
     android:icon="@drawable/ic_pref_time" 
     android:key="key_week" 
     android:title="Select Days" /> 

    <ListPreference 
     android:id="@+id/pref_track" 
     android:defaultValue="0" 
     android:entries="@array/tracks_arrays" 
     android:entryValues="@array/tracks_arrays_values" 
     android:icon="@drawable/ic_music_note" 
     android:key="key_track" 
     android:summary="%s" 
     android:title="Select Track" /> 

</PreferenceScreen> 

style.xml은 불행하게도 쉽게 환경 설정 아이콘을 착색하는 쉬운 방법이 없습니다. 내 솔루션, 벡터 아이콘을 사용하는 경우 각 이미지의 XML에 통합 할 속성을 만드는 것입니다. 값

/attrs.xml이 각 아이콘

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <attr name="iconPreferenceColor" format="reference|color" /> 
</resources> 

로이드 추가 : "ATTR/iconPreferenceColor"하고 fillColor =, 샘플 :

<vector xmlns:android="http://schemas.android.com/apk/res/android" 
     android:width="24dp" 
     android:height="24dp" 
     android:viewportWidth="24.0" 
     android:viewportHeight="24.0"> 
    <path 
     android:fillColor="?attr/iconPreferenceColor" 
     android:pathData="M13,2.05v3.03c3.39,0.49 6,3.39 6,6.92 0,0.9 -0.18,1.75 -0.48,2.54l2.6,1.53c0.56,-1.24 0.88,-2.62 0.88,-4.07 0,-5.18 -3.95,-9.45 -9,-9.95zM12,19c-3.87,0 -7,-3.13 -7,-7 0,-3.53 2.61,-6.43 6,-6.92V2.05c-5.06,0.5 -9,4.76 -9,9.95 0,5.52 4.47,10 9.99,10 3.31,0 6.24,-1.61 8.06,-4.09l-2.6,-1.53C16.17,17.98 14.21,19 12,19z"/> 
</vector> 

및 예약 스타일 :

<item name="iconPreferenceColor">@color/green</item>