Detailed explanation of selector effect example of Android ImageView

Detailed explanation of selector effect example of Android ImageView

In normal development, such as button, we add a selector to it to present the pressed and normal effects respectively, which can greatly enhance our user experience. However, when we use ImageView as "buttons", we find that setting the selector directly does not work. Of course, our application is dim at this time. Then we can only find a way to solve this situation.

First, define a selector file:

Step 2: set the selector to the SRC of ImageView.

Then the image resources to be presented on our ImageView are used

In other words, we set the backgroundresource for ImageView, and then set the selector we set for Src. Visually, our selector is displayed above ImageView. Of course, when we click ImageView, we trigger the selector, which will have the effect of pressing.

The above is the custom development of Android ImageView. Many things need to be rewritten for Android. It is certainly not a good app. There are many articles on Android Development on this site. Please refer to them. Thank you for your support for this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>