按鈕點擊沒有觸摸效果的解決

在android studio中,多個model組成的project這種項目下,非主工程中出現了不管怎樣都無發設置觸摸效果的狀況,android

第一種解決是:用一個ReleativeLayout包裹而後給ReleativeLayout設置background的selector,生效。google

第二種方式是:xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ic_login_google" android:state_pressed="false" android:state_focused="false"/>
    <item android:drawable="@drawable/ic_login_google_p" android:state_pressed="true"/>
    <item android:drawable="@drawable/ic_login_google_p" android:state_focused="true"/>
</selector>

在默認的item中也要設置state_pressed爲false和state_focused爲false,不然不管如何也沒有效果,至於爲何會出現這種狀況,還不知道utf-8

相關文章
相關標籤/搜索