Using shape and selector to achieve click effect, shapeselector
<Span style = "font-family: Arial, Helvetica, sans-serif; font-size: 18px; background-color: rgb (255,255,255);"> sometimes it is easy for us, if you don't want to give us images, you can't do it or offend the artist. But we can use colors to achieve our click effect! </Span>
<span style="font-family: Arial, Helvetica, sans-serif;"><?xml version="1.0" encoding="UTF-8"?></span><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:angle="90" android:endColor="#ffff99" android:startColor="#ffff99" /> <corners android:radius="20dp" /></shape>
<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:angle="90" android:endColor="#cc3935" android:startColor="#cc3935" /> <corners android:radius="20dp" /></shape>
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/red_shape" android:state_pressed="true"/> <item android:drawable="@drawable/gray_shape"/></selector>
Do it yourself !!!!!!!!!!
Android uses selector to implement imageview. The default value is gray. After being clicked, it turns blue and remains blue.
<? Xml version = "1.0" encoding = "UTF-8"?>
<Selector xmlns: android = "schemas.android.com/apk/res/android">
<Item android: state_pressed = "true" android: drawable = "@ drawable/appreciate_challenge_select"/> <! -- Pressed -->
<Item android: drawable = "@ drawable/appreciate_challenge_default"/> <! -- Default -->
</Selector>
To keep a color, you can set it after clicking
In android ListView, You need to click a certain part of the content. The clicking effect is implemented by selector, but clicking other parts in ListView also works.
Generally, the clicking effect of a single view is placed on the button.
If there is a button in the item, it will cause the focus issue. You need to control it through android: descendantFocusability = "blocksDescendants ".
In this way, you can achieve your effect.