如何改变一个微调的形象形象

由网友(少年不再年少)分享简介:如果我们看到一个喷丝它看起来像一个TextView和与图像到的TextView的右侧。在摩托罗拉里程碑的形象是向下的箭头,而在三星GALAXY ACE这是正确的方向。我可以用下面的code设置背景​​图片为微调。但我DONOT想改变的背景图像。我想改变这种形象。如何设置一个微调的这种形象。微调SP1 =(微调)find...

如果我们看到一个喷丝它看起来像一个TextView和与图像到的TextView的右侧。在摩托罗拉里程碑的形象是向下的箭头,而在三星GALAXY ACE这是正确的方向。我可以用下面的code设置背景​​图片为微调。但我DONOT想改变的背景图像。我想改变这种形象。如何设置一个微调的这种形象。

 微调SP1 =(微调)findViewById(R.id.spnContactTypes1);
sp1.setBackgroundResource(R.drawable.icon);
 

解决方案 沙龙活动 迷人的魅力是你自己创造出来的,穿得对,比穿的美更重要

您需要变化微调选择

这是与完成的:

 <微调机器人:ID =@ + ID / my_spinner
 机器人:layout_width =FILL_PARENT
 机器人:layout_height =WRAP_CONTENT
 机器人:drawSelectorOnTop =真
 机器人:spinnerSelector =@可绘制/ myspinner_selector>
 

myspinner_selector.xml

 < XML版本=1.0编码=UTF-8&GT?;
<选择的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
  <项目安卓state_first =真
      机器人:state_dropdown_showing =真
      机器人:可绘制=@可绘制/ btn_dropdown_down/>
<! - 其他国家..​​.  - >
< /选择器>
 

If we see a spinner it looks like a textview and with an image to the right of textview. In Motorola milestone that image is down arrow while in Samsung galaxy ace it is right arrow. I can set background image to a spinner using the following code. But I donot want to change the background image. I want to change that image. How to set that image of a spinner.

Spinner sp1 = (Spinner) findViewById(R.id.spnContactTypes1);
sp1.setBackgroundResource(R.drawable.icon);

解决方案

You want to change the spinner selector

This is done with:

<Spinner android:id="@+id/my_spinner"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:drawSelectorOnTop="true"
 android:spinnerSelector="@drawable/myspinner_selector">

and in myspinner_selector.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_first="true"
      android:state_dropdown_showing="true"
      android:drawable="@drawable/btn_dropdown_down"/>  
<!-- other states ... -->
</selector>

阅读全文

相关推荐

最新文章