您好,登錄后才能下訂單哦!
想要自定義Button的觸摸反饋效果,可以通過以下步驟實現(xiàn):
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/colorAccent" />
<item android:drawable="@color/colorPrimary" />
</selector>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom Button"
android:background="@drawable/custom_button_bg" />
<style name="CustomButtonStyle" parent="Widget.AppCompat.Button">
<item name="android:background">@drawable/custom_button_bg</item>
<item name="android:stateListAnimator">@null</item>
</style>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom Button"
style="@style/CustomButtonStyle" />
通過以上步驟,可以自定義Button的觸摸反饋效果,使其在按下時顯示不同的顏色或效果??梢愿鶕?jù)需求自定義drawable資源文件和樣式,實現(xiàn)不同的觸摸反饋效果。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。