更改小三角形色纺纱的机器人 [英] Change colour of small triangle on spinner in android

查看:125
本文介绍了更改小三角形色纺纱的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能改变的小三角形的颜色,在微调的右下角像显示的图像? 它显示默认的灰色现在。像这样

How can I change the colour of small triangle at the bottom right corner of spinner like shown in the image? It is showing default grey colour right now. like this

推荐答案

要获得正确的图像,你可以去 Android的资产工作室网站,并选择 Android的全息颜色生成器。这将创建一个所有你可能需要的资产,其中包括三角。它还生成实现更改的XML文件。

To get the correct images, you can go to Android Asset Studio site and choose the Android Holo Colors Generator. This will create all the assets you might need, including the "triangle". It also generates the XML files that implement the changes.

下面是示例XML文件:

Here are the example XML files:

自定义颜色:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="apptheme_color">#33b5e5</color>
</resources>

自定义微调方式:

Custom Spinner Style:

<?xml version="1.0" encoding="utf-8"?>

<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">

  <style name="SpinnerAppTheme" parent="android:Widget.Spinner">
      <item name="android:background">@drawable/apptheme_spinner_background_holo_light</item>
      <item name="android:dropDownSelector">@drawable/apptheme_list_selector_holo_light</item>
  </style>

  <style name="SpinnerDropDownItemAppTheme" parent="android:Widget.DropDownItem.Spinner">
      <item name="android:checkMark">@drawable/apptheme_btn_radio_holo_light</item>
  </style>
</resources>

自定义应用主题:

Custom Application Theme:

<?xml version="1.0" encoding="utf-8"?>

<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">

  <style name="AppTheme" parent="@style/_AppTheme"/>

  <style name="_AppTheme" parent="Theme.AppCompat.Light">

    <item name="android:spinnerStyle">@style/SpinnerAppTheme</item>

    <item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItemAppTheme</item>

  </style>

</resources>


正如你所看到的,有一些是由这些样式引用也有很多可绘制。


As you can see, there are also many drawables that are referenced by these styles.

下面是一个具体的三角你想改变:

Here is the one specific to the "triangle" you want to change:

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false"
          android:drawable="@drawable/apptheme_spinner_disabled_holo_light" />
    <item android:state_pressed="true"
          android:drawable="@drawable/apptheme_spinner_pressed_holo_light" />
    <item android:state_pressed="false" android:state_focused="true"
          android:drawable="@drawable/apptheme_spinner_focused_holo_light" />
    <item android:drawable="@drawable/apptheme_spinner_default_holo_light" />
</selector>

我不认为这是正确的地方完全列出所有的文件,因为你可以从引用的工具,让他们都直接。

I don't think this is the right place to list every file completely, since you can get them all directly from the referenced tool.

注意:这是一段主题,你的整个应用程序,以便所有的纺纱更新为自定义样式。

Note: this is the way to theme your whole app so that all spinners are updated to the custom style.

如果您正在寻找一个快速和肮脏的方法来改变只是一个微调,然后检查了里奇在他的评论中引用的文章:

If you are looking for a quick and dirty way to change just one spinner, then check out that article referenced by Ricky in his comment:

我建议无论如何读它,因为它解释的过程非常顺利,并会帮助你理解我的答案的其余部分。

I recommend reading it anyway, because it explains the process very well, and will help you to understand the rest of my answer.

这篇关于更改小三角形色纺纱的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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