我做了一个按钮,改变了不同状态下的背景,这样:
<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,就像我对drawable一样,但我无法做到。我已经尝试过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"
/>
有人有线索吗?
人到中年有点甜
相关分类