设计一个微调我想设计一个微调下面显示的图像:如何在Android的
我没有收到指向微调下行箭头符号。我怎样才能做到这一点?
如果我按照上面所显示的按钮设计,那么我必须编写额外的代码才能获得与微调控件类似的功能,因为微调控件没有android:drawableRight="@drawable/arraodown"
,但在按钮中我们有此方法。
设计一个微调我想设计一个微调下面显示的图像:如何在Android的
我没有收到指向微调下行箭头符号。我怎样才能做到这一点?
如果我按照上面所显示的按钮设计,那么我必须编写额外的代码才能获得与微调控件类似的功能,因为微调控件没有android:drawableRight="@drawable/arraodown"
,但在按钮中我们有此方法。
不要乱用右/左/ ... drawables。
只需设置一个9-补丁可绘制为限制内容的背景。
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/you_spinner_drawable" />
关于9补丁绘制看看Android的资源或从this blog post(其中显示了更多的细节就如何使一个自定义的微调)拍摄这个例子图片:
的信息约9补丁可绘看到Android文档: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch http://developer.android.com/tools/help/draw9patch.html
当然,你也可以指定一个状态列表XML文件作为可绘制的,例如。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When disabled -->
<item android:state_enabled="false"
android:drawable="@drawable/your_disabled_spinner_drawable" />
<!-- When selected -->
<item android:state_pressed="true"
android:drawable="@drawable/your_selected_spinner_drawable" />
<!-- When not selected-->
<item
android:drawable="@drawable/your_default_spinner_drawable" />
</selector>
http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
非常感谢..我真的甚至没有想过它。帽子关闭.. –
您必须为微调器创建自定义布局。我认为以下XML可能会给你一个想法。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dip">
<TextView
android:id="@+id/number"
android:padding="3dip"
android:layout_marginTop="2dip"
android:layout_marginLeft="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
抛出了非法异常,并且它仅要求“TextView”布局。你有没有得到一个工作样本? – rupinderjeet
只需使用GIMP作为您的图像编辑器,并更改背景颜色和边框用你喜欢的颜色。
例如,我可以通过编辑现有一个我在网上查到这样做形象:http://sdrv.ms/1lRkTbG
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/you_spinner_drawable" />
**You can use the below mentioned Drawable to set as background for this spinner**.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When disabled -->
<item android:state_enabled="false"
android:drawable="@drawable/your_disabled_spinner_drawable" />
<!-- When selected -->
<item android:state_pressed="true"
android:drawable="@drawable/your_selected_spinner_drawable" />
<!-- When not selected-->
<item
android:drawable="@drawable/your_default_spinner_drawable" />
</selector>
我使用ArrayAdapter adapter_subject =新ArrayAdapter (ActivityName.this,android.R.layout。 simple_spinner_dropdown_item,ArrayListData); \t spinner_name.setAdapter(adapter_subject); –