小编big*_*duk的帖子

Android Spinner文本背景颜色和主题

自从我尝试向我的应用程序添加主题以来,我遇到了一个问题.目前我只是使用主题来改变屏幕的背景颜色.问题是,除了屏幕更改为主题颜色的背景外,微调控件中文本的背景也会更改为该颜色.显示下拉菜单时,微调控制器将被块背景颜色替换.

主题定义如下:

<style name="Theme" parent="android:style/Theme">
</style>

<style name="Theme.Pink">
       <item name="android:background">#ffc0cb</item>
</style>

<style name="Theme.Yellow">
       <item name="android:background">#FFE97E</item>
</style> 
Run Code Online (Sandbox Code Playgroud)

主题在Activity OnCreate中设置:

setTheme(R.style.Theme.Yellow);
Run Code Online (Sandbox Code Playgroud)

Spinner设置为:

    bowAdapter = new SimpleCursorAdapter(this, R.layout.spinner_style, bowCursor, 
                 new String[] { DBAdapter.KEY_BOW_NAME }, 
                 new int[] { android.R.id.text1 });
    bowAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    bowSelectSpinner.setAdapter(bowAdapter);
Run Code Online (Sandbox Code Playgroud)

spinner_style.xml包含

<?xml version="1.0" encoding="UTF-8"?>
<TextView xmlns:android= "http://schemas.android.com/apk/res/android"
                android:id="@android:id/text1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textSize="@dimen/but_txt_size"
        android:textColor="@android:color/white"
        android:gravity="center" 
        android:ellipsize="marquee" />
Run Code Online (Sandbox Code Playgroud)

如何阻止微调器拾取主题中指定的背景颜色?

我已经在这里待了2天,所以任何提示都很感激

android android-layout

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

android-layout ×1