所选按钮android的文本颜色

时间:2012-06-13 19:20:19

标签: android button textcolor

我有一个像这样的按钮:

<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" />

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

1 个答案:

答案 0 :(得分:0)

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

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