如何设计在Android的一个微调 [英] How to design a spinner in Android

查看:184
本文介绍了如何设计在Android的一个微调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设计一个微调的显示如下图所示:

I want to design a spinner as displayed in the image below:

我没有收到指向下行的微调箭头符号。我怎样才能做到这一点?

I am not getting the arrow symbol pointing downside in spinner. How can I do this?

如果我做一个按钮的设计像上图所示,然后我不得不编写额外的code以获得类似的功能,作为一个微调,因为微调没有安卓drawableRight =@可绘制/ arraodown,但在按钮,我们有这个方法。

If I make a button design like shown above then I have to write extra code to get similar functionality as for a spinner, as Spinner doesn't have android:drawableRight="@drawable/arraodown", but in the button we have this method.

推荐答案

不要惹周围的左/右/ ...可绘制。

Do not mess around with right/left/... drawables.

刚刚成立一个9补丁绘制的背景下,限制内部内容。

Just set one 9-patch drawable as background that limits the inner content.

<Spinner
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/you_spinner_drawable" />

关于9补丁绘制看看android的资源,或从的这个博客帖子(这表明在如何使一个自定义的微调更多的细节):

Regarding the 9-patch drawable have a look at the android resources or at this example picture taken from this blog post (which shows in little more detail on how to make a custom spinner):

有关信息约9补丁可绘制看到Android的文档: <一href="http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch">http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch <一href="http://developer.android.com/tools/help/draw9patch.html">http://developer.android.com/tools/help/draw9patch.html

For information about 9-patch drawables see the android documentation: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch http://developer.android.com/tools/help/draw9patch.html

当然,你也可以指定一个国家列表XML文件绘制,如:

Of course you can also specify a State list xml file as drawable, eg.

<?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>

<一个href="http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList">http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

这篇关于如何设计在Android的一个微调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆