为什么我放开按钮后颜色不恢复
bg 和selector 与老师设置的是一样的,但是在真机上面跑的时候,按下了button,就一直是灰色,松开按钮后无法恢复到白色。请问是什么原因呢?
white_bg:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <corners android:radius="5dp"/> <solid android:color="@color/white"/> </shape>
white_selector:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/gray_bg" android:state_pressed="true"/> <item android:drawable="@drawable/white_bg" android:state_pressed="false"/> </selector>
gray_bg:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <corners android:radius="5dp"/> <solid android:color="@color/gray"/> </shape>
button对background的引用:
<Button android:id="@+id/button_point" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginLeft="8dp" android:layout_marginTop="8dp" android:layout_weight="1" android:background="@drawable/white_selector" android:gravity="right|bottom" android:paddingBottom="10dp" android:paddingRight="10dp" android:text="." android:textSize="25sp" />