How To Change The Shape Of An Onclick Highlight?
I currently have icons in a GridView on my app. When they are clicked, an orange square appears around them briefly as a highlight. The only problem is that I think this looks amat
Solution 1:
First, in your layout file, specify a drawable background:
android:background="@drawable/bg_your_view"Then edit the bg_your_view file which is in drawable:
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android" ><itemandroid:drawable="@drawable/bg_your_view_pressed"android:state_pressed="true"></item><itemandroid:drawable="@drawable/bg_your_view_normal"android:state_focused="false"></item></selector>At last, create corresponding drawable files for pressed and normal states:
- bg_your_view_pressed.xml contains the shape, the color you want for highlight.
- bg_your_view_normal.xml is similar, just without highlight effect.
Solution 2:
I've decided that the easiest way to solve this problem is to simply reference another image when the image on the GridView has been clicked. This means that the second image can just be edited in Photoshop in order to have a glow around it.
Post a Comment for "How To Change The Shape Of An Onclick Highlight?"