2015-01-04 3 views
0

내가 무엇을 하든지간에, 작업 표시 줄 텍스트가 검은 색이어서 흰색으로 바꿔야합니다.Android Lollipop에서 android 작업 표시 줄의 텍스트 색상을 변경하는 방법은 무엇입니까?

난 그냥 프로그램을 충돌, 여기 How to change action bar title color in code에서

int titleId = getResources().getIdentifier("action_bar_title", "id", "android"); 
TextView abTitle = (TextView) findViewById(titleId); 
abTitle.setTextColor(colorId); 

두 번째 대답이

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> 
    <item name="android:colorPrimary">@color/primary_color</item> 
    <item name="android:actionBarStyle">@style/AppTheme.ActionBar.TitleTextStyle</item> 
</style> 

<style name="AppTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Medium"> 
    <item name="android:textColorPrimary">@android:color/white</item> 
</style> 

이 시도 한 첫 번째 대답은 작동하지 않습니다. 도와주세요?? 새로운 디렉토리 내부

답변

0

복사 style.xmlvalues-v21을 불러 단순히이 교체 : 고해상도/값에 추가 : 자세한 내용은

<resources> 
    <!-- inherit from the material theme --> 
    <style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar"> 
     <!-- Main theme colors --> 
     <!-- your app branding color for the app bar --> 
     <item name="android:colorPrimary">@color/primary</item> 
     <!-- darker variant for the status bar and contextual app bars --> 
     <item name="android:colorPrimaryDark">@color/primary_dark</item> 
     <!-- theme UI controls like checkboxes and text fields --> 
     <item name="android:colorAccent">@color/accent</item> 
    </style> 

이이 일을해야 Maintaining Compatibility

0

참조 /styles.xml

<resources> 

    <style name="AppTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar"> 
     <item name="android:colorPrimary">@color/primary_color</item> 
     <item name="android:actionBarStyle">@style/MyActionBar</item> 
    </style> 

    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse"> 
     <item name="android:titleTextStyle">@style/Textstyle</item> 
    </style> 

    <style name="Textstyle" parent="@android:style/Widget.TextView"> 
     <item name="android:textColor">@android:color/white</item> 
    </style> 

</resources> 

그리고 AndroidManifest를 변경하십시오.

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme"> // <--------- Here --------> 

    <activity 
     android:name=".Main"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 
관련 문제