0
我試圖改變溢出菜單項的textColor
。通過XML覆蓋溢出菜單樣式
到目前爲止,我只找到解釋反射和/或在LayoutInflater上設置一個工廠的代碼,檢查視圖的名稱是否是一些內部menuItem
,返回具有正確樣式的TextView。
當然,應該有一個可以覆蓋的主題風格。有誰知道如何?
我試圖改變溢出菜單項的textColor
。通過XML覆蓋溢出菜單樣式
到目前爲止,我只找到解釋反射和/或在LayoutInflater上設置一個工廠的代碼,檢查視圖的名稱是否是一些內部menuItem
,返回具有正確樣式的TextView。
當然,應該有一個可以覆蓋的主題風格。有誰知道如何?
在瀏覽了很多StackOverflow的問題和答案以及博客文章後,我終於找到了覆蓋的正確樣式。
在定義你的應用程序的主題style.xml或theme.xml,包括:
<resources>
<style name="Theme.AppTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarWidgetTheme">@style/OverflowTextStyle</item>
</style>
</rescources>
style屬性要覆蓋是android:actionBarWidgetTheme
。將該項目包含在主題主題聲明中。 (我第一次預計它在定義android:actionBarStyle
定義,但不是屬於它的地方;它只是你的應用程序的主題內的項目)
現在我們要做的是什麼地方申報OverflowTextStyle
風格:
<resources>
<style name="OverflowTextStyle">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">18sp</item>
</style>
</resources>