Tag: android selector

Android自定义button; 改变文字颜色

我做了一个button,这样可以在不同状态下修改背景: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/btn_location_pressed" /> <!– pressed –> <item android:state_focused="true" android:drawable="@drawable/btn_location_pressed"/> <!– focused –> <item android:drawable="@drawable/btn_location"/> <!– default –> 这里的问题是,我也试图改变textColor,因为我用可绘制的,但我不能。 我已经尝试过android:textColor和android:color,但是第一个不工作,而秒改变我的背景。 下一个代码是我的布局的一部分。 关于文字颜色,它只适用于正常状态的文字颜色,因此在按下时不会将其改为白色 <Button android:id="@+id/location_name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="5dp" android:background="@drawable/location" android:textSize="15sp" android:textColor="@color/location_color" android:textColorHighlight="#FFFFFF" /> 有人有线索吗?