突出显示选定的图库查看项目

发布于 2024-12-11 16:00:21 字数 253 浏览 0 评论 0原文

我有一个 GalleryView,它始终显示 100 张图片。中心图片(默认情况下在应用程序加载时或当用户单击水平滚动列表中的另一张图片时)显示在 ImageView 下方的较大空间中。我想在 GalleryView 中突出显示所选图片,可能具有比其他图片更亮的边框,以便它作为用户选择的图片脱颖而出。现在,即使中心图片处于焦点中,它也具有与旁边的其他图片相同的边框、外观和感觉。我希望它在视觉上有所区别。

有人可以帮助我开始吗?

谢谢,

艾布

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青丝拂面 2024-12-18 16:00:21

使用此 xml 在单击时突出显示 gridview 中的视图:

selector.xml

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

其中,highlight_border 是您拥有的可绘制边框,它是突出显示的边框。

然后在包含每个 gridview 元素的 xml 文件中,输入:

grid_view_element.xml

<Element your using (like a LinearLayout or TextView
  ...
  background="@drawable/selector"
/>

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"
/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文