如何获得微调框的下拉箭头图像资源?

时间:2018-12-31 08:36:54

标签: android spinner android-resources

我想在自己制作的自定义控件中使用该箭头图像,有没有办法获取该资产?

我知道我可以从材料设计中的图标下载类似的图片:

https://material.io/tools/icons/?icon=arrow_drop_down&style=baseline

但是那些是黑色的,而微调框是灰色的。另外,如果微调器包含该资产,则该资产已经包含在应用程序中,因此拥有2个几乎相同的资产会让人感到愚蠢。

它有一个ID吗?

1 个答案:

答案 0 :(得分:1)

没有用于微调框下拉箭头的图像资源,它是用于btn_dropdown的图像资源。

btn_dropdown xml文件位置为:

C:\Users\Administrator\AppData\Local\Android\Sdk\platforms\android-28\data\res\drawable\btn_dropdown

及其以下内容:

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 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_window_focused="false" android:state_enabled="true"
        android:drawable="@drawable/btn_dropdown_normal" />
    <item
        android:state_window_focused="false" android:state_enabled="false"
        android:drawable="@drawable/btn_dropdown_disabled" />
    <item
        android:state_pressed="true"
        android:drawable="@drawable/btn_dropdown_pressed" />
    <item
        android:state_focused="true" android:state_enabled="true"
        android:drawable="@drawable/btn_dropdown_selected" />
    <item
        android:state_enabled="true"
        android:drawable="@drawable/btn_dropdown_normal" />
    <item
        android:state_focused="true"
        android:drawable="@drawable/btn_dropdown_disabled_focused" />
    <item
        android:drawable="@drawable/btn_dropdown_disabled" />
</selector>

您可以在上述文件中找到特定的可绘制文件,例如:

名称:btn_dropdown_normal.9.png(这是您想要的!)

位置:C:\ Users \ Administrator \ AppData \ Local \ Android \ Sdk \ platforms \ android-28 \ data \ res \ drawable-hdpi \