2014-09-29 6 views
2

Я хочу изменить цвет в панели действий и изменить заднюю узкую иконку. его работа, когда я просто меняю заднюю часть узкой, но когда я стилю цвет в панели действий, значок исчез. Я хочу изменить цвет панели действий на синий цвет.как изменить назад узкий и изменить цвет в панели действий

это мой код в XML:

<?xml version="1.0" encoding="utf-8"?> 

<!-- 
    Base application theme, dependent on API level. This theme is replaced 
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 


--> 
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> 
    <!-- 
     Theme customizations available in newer API levels can go in 
     res/values-vXX/styles.xml, while customizations related to 
     backward-compatibility can go here. 

    --> 
</style> 

<style name="AppBaseAlternativeTheme" parent="android:Theme.Holo.Light"> 
    <item name="android:actionBarStyle">@style/MyActionBar</item> 
</style> 

<!-- Application theme. --> 
<style name="AppTheme" parent="AppBaseTheme"> 
    <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
</style> 

<style name="AppAlternativeTheme" parent="AppBaseAlternativeTheme"> 
    <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
</style> 

<style name="CustomUpIndicatorTheme" parent="AppAlternativeTheme"> 
    <item name="android:homeAsUpIndicator">@drawable/ic_up_indicator</item> 
</style> 

    <!-- ActionBar styles --> 
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid"> 
    <item name="android:background">@color/action_bar</item> 
</style> 

ответ

5

Вы можете сделать это с помощью следующего кода в деятельности.

getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_actionbar_screen_back); 
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.actionbar_background_color))); 
2

попробовать it-

ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#ffffffff")); 
getSupportActionBar().setBackgroundDrawable(colorDrawable); 
Смежные вопросы