开发者

Highlight clickable images when touching the layout

I have a grid view with some clickable images. When I touch the layout is there a way to highlight only the click开发者_JAVA技巧able images.


You can leave a margin around the images in the gridview and then when the layout is touched you can set a different background color for those clickable images.


you need to creat two image one for Normal mode(button) and second for selected mode(button_selected)..

after then create one xml like as selectable.xml and put it in drawable folder

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

after then apply this xml in background of your imageview

like as

android:background="@drawable/selectable"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜