【问题标题】:android:textColorHighlight for android Switch not workingandroid:textColorHighlight for android Switch 不工作
【发布时间】:2014-02-04 23:58:38
【问题描述】:

我需要在 android 切换按钮中更改两边的颜色。我尝试在我的 xml 文件中使用 android:textColorHighlight,但它似乎不起作用。这是我的代码:

 <Switch
                android:id="@+id/sdrt"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:textColorHighlight="@android:color/holo_green_dark"
                android:textOff="0"
                android:textOn="1" />

如何更改 android switch 中选中和未选中按钮的背景颜色?

【问题讨论】:

标签: android android-layout switch-statement background-color


【解决方案1】:

根据文档,textColorHighlight 不会更改按钮的背景颜色。您可以使用样式设置按钮的背景颜色。

请参考How to set the text style of a button in selectors?

【讨论】:

    【解决方案2】:

    看起来像一个错误。你必须调用 myTextView.setHighlightColor(Color.RED);例如在代码中......从 xml 调用时似乎不起作用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-02
      • 1970-01-01
      • 1970-01-01
      • 2012-02-08
      相关资源
      最近更新 更多