如何突出的ImageView集中或在单击时? [英] How to highlight ImageView when focused or clicked?

查看:237
本文介绍了如何突出的ImageView集中或在单击时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这方面的一个很好的例子,或者是在Twitter上发布屏幕,甚至只看该应用程序托盘,当你专注的应用程序图标(与当应用程序是首先推出的是看到了大图标的屏幕)。

A good example of this is either on the Twitter launch screen (the screen with the large icons that is seen when the application is first launch) or even just look at the application tray when you focus an application icon.

基本上,我需要强调的ImageView的加亮轮廓到的ImageView内的图像,看起来就像是到该图像的边框。我也想定制的亮点,有它一定的色差,并为它淡出。

Basically I need to highlight an ImageView where the highlight contours to the image within the ImageView and looks like it's a border to that image. I would also like to customize the highlight to have it be a certain color and for it to fade out.

谢谢

groomsy

推荐答案

您需要分配的ImageView的的src 属性的状态列表绘制。换句话说,该国清单将有选择,pressed,不选等不同的图像 - 这就是Twitter的应用程序是怎么做的。

You need to assign the src attribute of the ImageView a state list drawable. In other words, that state list would have a different image for selected, pressed, not selected, etc. - that's how the Twitter App does it.

所以,如果你有一个ImageView的:

So if you had an ImageView:

<ImageView style="@style/TitleBarLogo"
            android:contentDescription="@string/description_logo"
            android:src="@drawable/title_logo" />

在src绘制(title_logo.xml)是这样的:

The src drawable (title_logo.xml) would look like this:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/title_logo_pressed"/>
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/title_logo_pressed"/>
    <item android:state_focused="true" android:drawable="@drawable/title_logo_selected"/>
    <item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/title_logo_default"/>
</selector>

借助谷歌IO调度应用有一个很好的例子。

The Google IO Schedule app has a good example of this.

这篇关于如何突出的ImageView集中或在单击时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆