Question

I have a GalleryView which displays 100s of pictures at all times. The central picture (by default on application load or when user clicks on another picture in the horz. scroll list) is displayed in the larger space below in an ImageView. I would like to highlight the selected picture in the GalleryView, maybe with a brighter border than the rest so that it stands out as the user-selected picture. Right now, even though the central picture is in focus, it has the same border and look and feel like the rest of the pictures next to it. I would like it to be visually differentiated.

Can anyone help me get started?

Thanks,

Ab

Was it helpful?

Solution

Use this xml to highlight a view in your gridview when it's clicked on:

selector.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
    android:drawable="@android:drawable/highlight_border" />      
</selector>

Where highlight_border is a drawable you have that is a highlighted border.

Then in your xml file containing what each gridview element looks like, put this:

grid_view_element.xml

<Element your using (like a LinearLayout or TextView
  ...
  background="@drawable/selector"
/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top