【问题标题】:Text color of selected button android所选按钮android的文本颜色
【发布时间】:2012-06-13 19:20:18
【问题描述】:

我有一个这样的按钮:

<Button
        android:id="@+id/button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:text="Button"
        android:textColor="@color/my_gray" />

按下按钮后,文本颜色变为深灰色(“已按下”颜色)。我该如何防止这种情况?按下按钮时,我执行button.setTextColor(R.color.my_gray); 重置颜色,但没有效果。

【问题讨论】:

  • 您是否在按下按钮后在 UI 线程中进行了某种繁重的工作以阻止其返回正常状态?
  • 我只是在按下按钮时将视图设置为可见。
  • 奇怪,按钮还停留在按下状态?
  • 我不确定是不是按下状态。这似乎是一种“你已经推了我”的状态,就像一个链接在被点击后变成了不同的颜色。

标签: android button textcolor


【解决方案1】:

尝试使用其他类型的按钮。 CompoundButtonImageButton 可能适合您,因为您可以更轻松地控制它们的背景/图像。

但是,最好的方法可能是使用像 this guide 节目这样的选择器。

【讨论】:

  • 我想我实际上是在尝试复制一个复合按钮,但有点不同,所以我将其标记为正确。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-12-28
  • 2017-04-25
  • 2011-08-29
  • 2015-10-29
  • 2014-11-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多