v-21 ripple配合selector,state_enabled不起作用
ripple是android L之后新增的水波纹特效,当我们的按钮增加了特效后,state_enabled=false,让按钮置为灰色,不起作用了下面贴出代码
drawable btn_green.xml
1
2
3
4
5<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@color/pressed"></item>
<item android:state_enabled="false" android:drawable="@color/dark_gray"></item>
<item android:drawable="@color/green"/>
</selector>
drawable-21 btn_green.xml
1
2
3
4
5
6
7
8
9<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/pressed">
<item>
<selector >
<item android:state_enabled="true" android:drawable="@color/green"></item>
<item android:state_enabled="false" android:drawable="@color/dark_gray"></item>
</selector>
</item>
</ripple>
也就是说在新版的selector里面,没有默认状态,我们必须手动填写android:state_enabled="true"
Activity has leaked window that was originally added
报错但并不crash
原因:
因为使用了Dialog,但是未在activity销毁时,调用dismiss()。