2013-02-04 13 views
0

这是微调代码:无法获得所需的背景为IcsSpinner

<com.actionbarsherlock.internal.widget.IcsSpinner 
    android:id="@+id/mSpinner" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@color/bg_grey" /> 

bg_grey是第一图像中的浅灰色背景。

TextView的代码dropdown_text.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/mDropDown" 
    android:layout_width="fill_parent" 
    android:layout_height="30dp" 
    android:background="@android:color/transparent" 
    android:padding="2dp" 
    android:textColor="@color/text_dark_grey"> 
</TextView> 
在活动

:微调的

ArrayAdapter<String> ,Adapter = new ArrayAdapter<String>(mActivity.this, R.layout.dropdown_text, mArray); 

无效状态:

enter image description here

这就是我想要的。但是,在微调的

活动状态:

enter image description here

为什么下拉颜色暗灰色的背景。我希望它像第一张图像一样浅灰色。

谢谢

回答

0

更改您的TextView的背景:

<android:background="@color/bg_grey">

这并不能解释为什么它的暗灰色,但会解决它。

我有一个类似的问题与一个ListView的项目的背景颜色随机变化。当我改变了ListView项目的背景颜色时,他们就像我想要的那样。对我来说仍然是一种m y。

1

试试这个:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(mActivity.this, R.layout.dropdown_text, mArray){ 

      @Override 
      public View getDropDownView(int position, View convertView, 
        ViewGroup parent) { 
       TextView tv = super.getDropDownView(position, convertView, parent); 
       //set your own selector for textview background here 
       return tv; 
      } 

      @Override 
      public View getView(int position, View convertView, ViewGroup parent) { 

       TextView tv = super.getView(position, convertView, parent); 
       //set your own selector for textview background here 
       return tv; 
      } 

     };