【问题标题】:Remove underline on Spinner Drop down and Change the color of the triangle删除 Spinner Drop 上的下划线并更改三角形的颜色
【发布时间】:2013-12-25 17:47:01
【问题描述】:

我正在尝试将微调器添加到我的操作栏。我正在使用自定义微调器。这是代码。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/block" >

    <Spinner
        android:id="@+id/action_bar_spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:gravity="center" />

</RelativeLayout>

这是我在 SpinnerAdapter 的 getView 方法中添加的代码,用于获取微调器的自定义标题。它是一个文本视图。

android:id="@+id/spinner_title"
        style="@style/text_title"
        android:layout_alignParentRight="true"
        android:ellipsize="end"
        android:gravity="right"
        android:singleLine="true"
        android:text="@string/list_header"
        android:enabled="false" 

一切正常。但是我在微调器标题下方看到了一条下划线,我想更改微调器标题右侧三角形的默认灰色。

请指教。

【问题讨论】:

  • 可以发截图吗?
  • 嗨尼古拉。谢谢你的答复。我试图发布截图。但不能这样做,因为我需要 10 名声望才能上传图片。它是一个简单的微调器,在操作栏的中间有文本,比如 Sample 问题是它的下划线,它右边的三角形颜色是默认的灰色。我需要改变它。
  • Full explanation of Garegin's answer here,包括生成图片的网站链接。

标签: android drop-down-menu android-spinner


【解决方案1】:

下划线和三角形一起是一个九补丁资源,是Spinner的默认背景。您无法通过 xml 或代码更改三角形的颜色。您必须更改整个背景。

【讨论】:

  • 感谢您的回复。你能发布一些关于如何做到这一点的代码。我试过了,但无法正确实施。感谢您的帮助。
猜你喜欢
  • 2016-09-03
  • 2015-01-23
  • 2020-04-21
  • 2012-09-15
  • 1970-01-01
  • 2015-04-08
  • 2017-07-23
  • 1970-01-01
相关资源
最近更新 更多