• <legend id='IUEWi'><style id='IUEWi'><dir id='IUEWi'><q id='IUEWi'></q></dir></style></legend>

      • <bdo id='IUEWi'></bdo><ul id='IUEWi'></ul>
      <i id='IUEWi'><tr id='IUEWi'><dt id='IUEWi'><q id='IUEWi'><span id='IUEWi'><b id='IUEWi'><form id='IUEWi'><ins id='IUEWi'></ins><ul id='IUEWi'></ul><sub id='IUEWi'></sub></form><legend id='IUEWi'></legend><bdo id='IUEWi'><pre id='IUEWi'><center id='IUEWi'></center></pre></bdo></b><th id='IUEWi'></th></span></q></dt></tr></i><div id='IUEWi'><tfoot id='IUEWi'></tfoot><dl id='IUEWi'><fieldset id='IUEWi'></fieldset></dl></div>
        <tfoot id='IUEWi'></tfoot>
      1. <small id='IUEWi'></small><noframes id='IUEWi'>

        如何更改微调器弹出窗口的背景颜色?

        时间:2024-04-14

        • <bdo id='yfPd6'></bdo><ul id='yfPd6'></ul>
            • <tfoot id='yfPd6'></tfoot>
                  <tbody id='yfPd6'></tbody>

                <small id='yfPd6'></small><noframes id='yfPd6'>

                <i id='yfPd6'><tr id='yfPd6'><dt id='yfPd6'><q id='yfPd6'><span id='yfPd6'><b id='yfPd6'><form id='yfPd6'><ins id='yfPd6'></ins><ul id='yfPd6'></ul><sub id='yfPd6'></sub></form><legend id='yfPd6'></legend><bdo id='yfPd6'><pre id='yfPd6'><center id='yfPd6'></center></pre></bdo></b><th id='yfPd6'></th></span></q></dt></tr></i><div id='yfPd6'><tfoot id='yfPd6'></tfoot><dl id='yfPd6'><fieldset id='yfPd6'></fieldset></dl></div>

                1. <legend id='yfPd6'><style id='yfPd6'><dir id='yfPd6'><q id='yfPd6'></q></dir></style></legend>
                  本文介绍了如何更改微调器弹出窗口的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试设置微调器弹出窗口的背景颜色,但我尝试过的所有操作都无法正常工作.

                  I'm trying to set the background color of a spinner popup but everything I've tried didn't work properly.

                  这是微调控件:

                  <Spinner
                    android:id="@+id/myspinner"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="@null"
                    android:drawSelectorOnTop="true" />
                  

                  当我点击它时,它会显示一个带有白色背景的弹出窗口,我想更改它.

                  When I click on it, it shows a popup with a white background, and I want to change that.

                  我用来填充弹出窗口的 xml 行是:

                  The xml line which I use to populate the popup is:

                  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/list_selector"      
                    android:paddingBottom="@dimen/padding_medium"
                    android:layout_marginBottom="@dimen/padding_medium"
                    android:orientation="vertical">
                    
                    ..........
                  
                  </RelativeLayout>
                  

                  和可绘制背景 list_selector.xml:

                  and the drawable background list_selector.xml:

                  <selector xmlns:android="http://schemas.android.com/apk/res/android"> 
                    <!-- Pressed -->
                    <item 
                      android:state_pressed="true" 
                      android:drawable="@color/green" /> <!--  @drawable/tab_press -->
                  
                    <!-- Selected -->
                    <item 
                      android:state_selected="true" 
                      android:drawable="@color/green" /> <!--  @drawable/tab_press -->
                   
                  </selector> 
                  

                  给上面的xml添加一个默认状态是可以的,但是spinner主控件用那个背景颜色显示项目,我不想要那个.

                  Adding a default state to the above xml is ok, but the spinner main control shows the item with that background color, and I don't want that.

                  我尝试的另一件事是在styles.xml 中将应用程序背景颜色设置为黑色

                  Another thing I've tried is to set the application background color to black in styles.xml

                  <style name="AppTheme" parent="android:Theme.Light">
                       <item name="android:background">#000000</item>
                       <item name="android:textColor">#FFFFFF</item>
                       <item name="android:typeface">sans</item> 
                  </style>
                  

                  这也覆盖了弹出背景,但它具有不良的附带效果.有没有什么简单的方法可以做到这一点?

                  That overrides the popup background too, but it has undesirable collateral effects. Is there any way to accomplish this in a simple way?

                  PS:我使用的是 API 级别 10 (2.3.3),并且属性 android:popupBackground 不存在.

                  PS: I'm using API level 10 (2.3.3) and the attribute android:popupBackground doesn't exist.

                  推荐答案

                  以上解决方案都不适合我.

                  None of the above solutions worked for me.

                  解决方案是在传递给微调器的适配器中编写方法 getDropDownView 中的不同实现,以使用自定义颜色显示不同的布局:

                  The solution was writing in the adapter passed to the spinner a different implementation in the method getDropDownView to display a different layout with custom colors:

                  @Override
                  public View getView(int position, View convertView, ViewGroup parent) {
                      View vista = convertView;       
                  
                      // layout for spinner widget
                  
                      if (vista==null) {
                          LayoutInflater inflater = actividad.getLayoutInflater();
                          vista = inflater.inflate(R.layout.fila_colores_spinner, null);                  
                      }
                  
                      return vista;
                  }
                  
                  @Override
                  public View getDropDownView(int position, View convertView,ViewGroup parent) {
                      View vista = convertView;       
                  
                      //layout for spinner popup
                  
                      if (vista==null) {
                          LayoutInflater inflater = actividad.getLayoutInflater();
                          vista = inflater.inflate(R.layout.fila_colores_spinner_popup, null);                    
                      }
                  
                      return vista;
                  }
                  

                  这篇关于如何更改微调器弹出窗口的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何居中弹出窗口? 下一篇:如何在 android webview 中使用弹出窗口

                  相关文章

                  • <bdo id='ZV8KC'></bdo><ul id='ZV8KC'></ul>
                  <i id='ZV8KC'><tr id='ZV8KC'><dt id='ZV8KC'><q id='ZV8KC'><span id='ZV8KC'><b id='ZV8KC'><form id='ZV8KC'><ins id='ZV8KC'></ins><ul id='ZV8KC'></ul><sub id='ZV8KC'></sub></form><legend id='ZV8KC'></legend><bdo id='ZV8KC'><pre id='ZV8KC'><center id='ZV8KC'></center></pre></bdo></b><th id='ZV8KC'></th></span></q></dt></tr></i><div id='ZV8KC'><tfoot id='ZV8KC'></tfoot><dl id='ZV8KC'><fieldset id='ZV8KC'></fieldset></dl></div>
                  <tfoot id='ZV8KC'></tfoot><legend id='ZV8KC'><style id='ZV8KC'><dir id='ZV8KC'><q id='ZV8KC'></q></dir></style></legend>
                  1. <small id='ZV8KC'></small><noframes id='ZV8KC'>