【问题标题】:Change spinner item highlight color更改微调器项目突出显示颜色
【发布时间】:2014-11-18 02:29:09
【问题描述】:

我想将微调器项目高亮橙色更改为蓝色。 我遵循这个教程:http://androidopentutorials.com/android-how-to-get-holo-spinner-theme-in-android-2-x/

在 res/drawable-hdpi、res/drawable-mdpi、res/drawable-xhdpi 和 res/drawable-xxhdpi 中,我在 http://android-holo-colors.com/ 中创建了所有 .png 文件(以及 res/drawable 中的 .xml 文件)

In 能够更改微调器背景颜色(当用户点击微调器时)和单选按钮颜色。但是橙色高亮颜色(当用户点击对话框上的微调器项时)仍然是橙色。

我做错了什么?

主题.xml

<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">

</style>

<style name="AppBaseTheme.NoTitleBar" parent="@android:style/Theme.Light.NoTitleBar">

    <item name="android:windowBackground">@android:color/white</item>
    <item name="android:colorBackground">@android:color/white</item>

    <!-- Spinner themes -->
    <item name="android:spinnerStyle">@style/SpinnerTheme</item>
    <item name="android:dropDownSpinnerStyle">@style/SpinnerTheme.DropDown</item>
    <item name="android:spinnerDropDownItemStyle">@style/DropDownItemSpinnerTheme</item>
    <item name="android:listViewStyle">@style/ListViewSpinnerTheme</item>
    <item name="android:listViewWhiteStyle">@style/ListViewSpinnerTheme.White</item>
    <item name="android:spinnerItemStyle">@style/SpinnerItemTheme</item>
</style>
</resources>

styles.xml

<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="SpinnerTheme" parent="android:Widget.Spinner">
    <item name="android:background">@drawable/spinner_background_holo_light</item>
    <item name="android:dropDownSelector">@drawable/list_selector_holo_light</item>
</style>

<style name="SpinnerTheme.DropDown">
    <item name="android:spinnerMode">dialog</item>
</style>

<!-- Changes the spinner drop down item radio button style -->
<style name="DropDownItemSpinnerTheme" parent="android:Widget.DropDownItem.Spinner">
    <item name="android:checkMark">@drawable/btn_radio_holo_light</item>
</style>

<style name="ListViewSpinnerTheme" parent="android:Widget.ListView">
    <item name="android:listSelector">@drawable/list_selector_holo_light</item>
</style>

<style name="ListViewSpinnerTheme.White" parent="android:Widget.ListView.White">
    <item name="android:listSelector">@drawable/list_selector_holo_light</item>
</style>

<style name="SpinnerItemTheme" 
        parent="android:TextAppearance.Widget.TextView.SpinnerItem">
    <item name="android:textColor">#000000</item>
</style>

</resources>

colors.xml

<resources>

<color name="transparent">#00000000</color>

</resources>

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nsn.mywfm.mobile"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="18" />

...

<application
    android:allowBackup="true"
    android:icon="@drawable/logo_icon"
    android:label="@string/app_name"
    android:supportsRtl="false"
    android:theme="@style/AppBaseTheme.NoTitleBar" >
    <activity
    ...

【问题讨论】:

    标签: android styles spinner


    【解决方案1】:

    我想通了。

    主题.xml

    <resources>
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
        <item name="android:windowBackground">@android:color/white</item>
        <item name="android:colorBackground">@android:color/white</item>
    </style>
    </resources>
    

    styles.xml为空,不需要在res/drawable中生成图片和.xml文件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-13
      • 2013-06-06
      • 1970-01-01
      • 2010-12-12
      • 1970-01-01
      • 2018-04-19
      • 1970-01-01
      相关资源
      最近更新 更多