luj*_*jop 17 android android-theme
我正在使用继承自己的自定义主题,DarkActionBar我想将自定义下拉菜单设置为白色,就像使用Light Holo主题一样.
我已经能够使用以下方法将背景更改为白色:
<style name="MyTheme" parent="@style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
</style>
<style name="MyDropDownNav">
<item name="android:background">@drawable/spinner_background_white</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_whyite</item>
<item name="android:dropDownSelector">@drawable/selectable_background_white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但我没有任何关于如何将文字颜色改为黑色的线索.因为在设置白色drawable之后问题是文本不可见因为在白色背景是白色的.
luj*_*jop 21
经过一番调查我回答了自己.除了问题的样式,您还需要:
android:spinnerDropDownItemStyle的actionBarWidgetTheme更改它的文本外观.simple_dropdown_item_1line)没有问题.但如果您使用像我这样的自定义(可以添加图标),请不要忘记 style="?attr/spinnerDropDownItemStyle"在您的布局TextView中应用.然后最终的自定义样式是:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.myapp" parent="@style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">@style/myapp_DropDownNav</item>
<item name="android:actionBarWidgetTheme">@style/myapp.actionBarWidgetTheme</item>
</style>
<style name="myapp.actionBarWidgetTheme" parent="@style/Theme.">
<item name="android:spinnerDropDownItemStyle">@style/myapp.Widget.DropDownItem.Spinner</item>
</style>
<style name="myapp_DropDownNav" parent="@style/Widget.Spinner.DropDown.ActionBar">
<item name="background">@drawable/spinner_background_ab_myapp</item>
<item name="android:background">@drawable/spinner_background_ab_myapp</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_myapp</item>
<item name="android:dropDownSelector">@drawable/selectable_background_myapp</item>
</style>
<style name="myapp.Widget.DropDownItem.Spinner" parent="Widget.DropDownItem.Spinner">
<item name="android:textAppearance">@style/myapp.TextAppearance.Widget.DropDownItem</item>
</style>
<style name="myapp.TextAppearance.Widget.DropDownItem" parent="TextAppearance.Widget.DropDownItem">
<item name="android:textColor">@color/black</item>
</style>
Run Code Online (Sandbox Code Playgroud)
凡在可绘myapp_DropDownNav有白色背景的,你可以生成动作条式发电机在Android的资产工作室
| 归档时间: |
|
| 查看次数: |
43570 次 |
| 最近记录: |