2015-04-10 4 views
1

Ниже мой стиль:Как изменить ActionBar переполнения значок

<style name="AppBaseTheme" parent="Theme.AppCompat.Light"> 
     <!-- <item name="windowActionBar">false</item> --> 
    </style> 

    <style name="AppTheme" parent="AppBaseTheme"> 
     <item name="actionOverflowMenuStyle">@style/OverflowMenu</item> 
     <!-- <item name="actionBarStyle">@style/Theme.MyApp.ActionBar</item> --> 
    </style> 
<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow"> 

     <!-- Required for pre-Lollipop. --> 
     <item name="overlapAnchor">false</item> 

     <!-- Required for Lollipop. --> 
     <!-- <item name="android:overlapAnchor">false</item> --> 
    </style> 

Я использую ActionBarActivity из appcompact библиотеки поддержки, чтобы изменить цвет overflowbutton.

<style name="AppTheme" parent="AppBaseTheme"> 
     <item name="actionOverflowMenuStyle">@style/OverflowMenu</item> 
     <item name="android:actionOverflowButtonStyle">@style/OverFlowStyle</item> 

     <!-- <item name="actionBarStyle">@style/Theme.MyApp.ActionBar</item> --> 
    </style> 

    <style name="OverFlowStyle" parent="Widget.AppCompat.ActionButton.Overflow"> 
     <item name="android:src">@drawable/ic_empty</item> 
    </style> 
+0

для моего приложения Я просто изменить родитель AppTheme Theme.AppCompat.Light.DarkActionBar by Theme.AppCompat.Light или или наоборот – JFouad

ответ

2
<style name="OverFlowStyle" parent="@style/Widget.AppCompat.Light.ActionButton.Overflow"> 
      <item name="android:src">@drawable/green_overflow</item> 
     </style> 
    <style name="AppTheme" parent="AppBaseTheme"> 
    <item name="actionOverflowButtonStyle">@style/OverFlowStyle</item> 
      <item name="android:actionOverflowButtonStyle">@style/OverFlowStyle</item> 
</style> 
1

Как комментарий в ваших стилях предполагает, android: префикса требуется для леденца. Вы пробовали добавить его к атрибуту actionOverflowMenuStyle?

<item name="android:actionOverflowButtonStyle">@style/OverflowMenu</item> 
<item name="actionOverflowButtonStyle">@style/OverflowMenu</item> 
+0

i кнопка стилей стилей все еще не работает – Siri

1

Для android version < 21 Это должно быть так.

<style name="AppTheme" parent="AppBaseTheme"> 

     ... 
    <item name="actionOverflowButtonStyle">@style/OverFlowStyle</item> 
</style> 

<style name="OverFlowStyle" parent="Widget.AppCompat.ActionButton.Overflow"> 
    <item name="android:src">@drawable/ic_empty</item> 
</style> 
1

С панели инструментов, ни один из вышеперечисленных не работал для меня, и я должен был изменить его с помощью кода, используя ниже:

public static void setOverflowButtonColor(final Activity activity) { 
    final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description); 
    final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); 
    final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver(); 
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 
     @Override 
     public void onGlobalLayout() { 
      final ArrayList<View> outViews = new ArrayList<View>(); 
      decorView.findViewsWithText(outViews, overflowDescription, 
        View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION); 
      if (outViews.isEmpty()) { 
       return; 
      } 
      TintImageView overflow=(TintImageView) outViews.get(0); 
      overflow.setColorFilter(Color.CYAN); 
      removeOnGlobalLayoutListener(decorView,this); 
     } 
    }); 
} 

Complete source.

+0

Этот золь Очень полезно! –

Смежные вопросы