2013-04-16 77 views
17

Làm cách nào để thay đổi màu của biểu tượng tràn trong thanh tác vụ?Thay đổi màu biểu tượng cài đặt thanh tác vụ

enter image description here

(Biểu tượng đúng nhất)

+0

bạn có muốn thay đổi biểu tượng cài đặt (3 dấu chấm dọc) hay màu chữ của từng hạng mục? – Jaguar

+2

sidenote quan trọng: đây KHÔNG phải là nút cài đặt, mà là nút tràn. các thiết lập nên được trong tràn mặc dù. – Teovald

+0

Teovald, tôi đã cập nhật OP – tir38

Trả lời

26

Bạn có thể sử dụng một cái gì đó như thế này

<style name="MyTheme" parent="android:style/Theme.Holo.Light"> 
    <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item> 
</style> 

<style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.ActionButton.Overflow"> 
    <item name="android:src">@drawable/my_action_bTutton_overflow</item> 
</style> 

trong manifestfile

<application 
    android:theme="@style/MyTheme" > 

của bạn Nếu bạn muốn chane màu actionBar @ style/MyActionBar

 <!-- Support library compatibility --> 
     <item name="actionBarStyle">@style/MyActionBar</item> 
    </style> 

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

     <!-- Support library compatibility --> 
     <item name="background">@color/app_theme_color</item> 
     <item name="android:alwaysDrawnWithCache">true</item> 
     <item name="android:displayOptions">showTitle|showHome|homeAsUp</item> 
     <item name="android:icon">@android:color/transparent</item> 
    </style> 

Sau đó, trong bạn AndroidManifest.xml bạn cần tham khảo cái này bên trong thẻ application của bạn.

android:theme="@style/CustomActionBarTheme" 
+0

Cảm ơn, tôi tạo biểu tượng cài đặt của riêng mình (giống như bản gốc - chỉ màu khác) và đặt nó làm src. –

+0

Rất vui khi biết điều đó :) –

+1

Tôi chưa hiểu đầy đủ về android, vì vậy xin lỗi nếu tôi hiểu nhầm, nhưng để làm việc này cho tôi, tôi phải đặt ký hiệu '@' trước "MyActionButtonOverflow" s cha mẹ. "@android: style/Widget ..." – Logan

0

Bạn có thể sử dụng phong cách tùy chỉnh của bạn bên trong cho mục trình đơn, như thế này

<item name="android:itemTextAppearance">@style/myCustomMenuTextApearance</item> 

Xác định phong cách như thế này:

<style name="myCustomMenuTextApearance" parent="@android:style/TextAppearance.Widget.IconMenu.Item"> 
     <item name="android:textColor">@android:color/primary_text_dark</item> 
</style> 

Xem thêm Change the background color of the options menu

Android: customize application's menu (e.g background color)

2

Nó cũng đáng giá thêm rằng nếu bạn chỉ muốn thay đổi nút tràn sang màu sáng hoặc tối để đi với màu thanh hành động của bạn, điều này có thể được thực hiện mà không chỉ định biểu tượng tùy chỉnh.

Đối với một nút màu đen thiết lập chủ đề của bạn như:

<style name="MyTheme" parent="@style/Theme.AppCompat.Light"> 
    <item name="android:actionBarStyle">@style/MyTheme.ActionBar</item> 
</style> 

Theme.Holo.Light

Đối với một nút màu ánh sáng thêm DarkActionBar:

<style name="MyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> 
    <item name="android:actionBarStyle">@style/MyTheme.ActionBar</item> 
</style> 

Theme.Holo.Light.DarkActionBar

.210

Nếu, như tôi, bạn muốn có một nút màu ánh sáng nhưng bạn muốn menu tràn là ánh sáng bạn có thể làm như sau:

<style name="MyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> 
    <item name="android:actionBarStyle">@style/MyTheme.ActionBar</item> 
    <item name="android:actionBarWidgetTheme">@style/MyTheme.ActionBarWidget</item> 
</style> 
<!-- This helps the PopupMenu stick with Light theme while the ActionBar is in Dark theme --> 
<style name="MyTheme.ActionBarWidget" 
    parent="android:Theme.Holo.Light"> 
    <item name="android:popupMenuStyle">@android:style/Widget.Holo.Light.PopupMenu</item> 
    <item name="android:dropDownListViewStyle">@android:style/Widget.Holo.Light.ListView.DropDown</item> 
</style> 
3

Nếu bạn chỉ muốn thay đổi màu sắc bạn chỉ có thể nhuộm màu nó:

<style name="DotsDarkTheme" parent="@style/Widget.AppCompat.ActionButton.Overflow" > 
    <item name="android:tint">@color/yourColor</item> 
    </style> 

và sau đó sử dụng nó trong phong cách của bạn:

<item name="actionOverflowButtonStyle">@style/DotsDarkTheme</item> 
Các vấn đề liên quan