Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7985449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:33:30+00:00 2026-06-04T11:33:30+00:00

I have an ImageView, I’d like a selector such that when the user clicks

  • 0

I have an ImageView, I’d like a selector such that when the user clicks or otherwise has focus, a translucent color is drawn on top of the ImageView content. I’m not sure if this is possible with selectors (which I’ve been defining ok in the past with static drawables).

But basically I have a listview with imageview instances in each row, and wanted to do something like:

ImageView iv = ...;
iv.setBitmapDrawable(bitmapLoadedFromInternets()); // dynamic content
iv.setClickStateOverlayColor(0x33ff0000); // ?

Usually ImageView only takes a single drawable via setBitmapDrawable(), but a selector (1) swaps out the drawable for the different click states, whereas I just want a color overlay drawn, and (2) the off state is a dynamic bitmap, so I can’t reference that from a selector definition.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:33:32+00:00Added an answer on June 4, 2026 at 11:33 am

    You can do that pretty easily if you make your own subclass of ImageView. The method to use is setColorFilter. Something like this will do it:

    public class ImageView extends android.widget.ImageView
    {
        public ImageView(Context context)
        {
            super(context);
        }
    
        public ImageView(Context context, AttributeSet attrs)
        {
            super(context, attrs);
        }
    
        public ImageView(Context context, AttributeSet attrs, int defStyle)
        {
            super(context, attrs, defStyle);
        }
    
        @Override
        public boolean onTouchEvent(MotionEvent event)
        {
            if(event.getAction() == MotionEvent.ACTION_DOWN && isEnabled())
                setColorFilter(0x33ff0000, PorterDuff.Mode.MULTIPLY); //your color here
    
            if(event.getAction() == MotionEvent.ACTION_UP)
                setColorFilter(null);
    
            return super.onTouchEvent(event);
        }
    }
    

    You can then use it in your XML layouts just by referring to it fully qualified like my.package.ImageView instead of just ImageView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ImageView that has a drawable image resource set to a selector.
I have an ImageView at the top of my display that looks like the
I have an Imageview(like a Magazine page).When i swype in to that image then
I have an ImageView and over that ImageView i have drawn a Rect(top,left,right,bottom) which
I have an imageview that has a pinchgesturerecognizer attached to it. In the pinchgesturerecognizer
I have a imageview that I want to change the color based on a
I have a relative layout that has an ImageView and and a textview aligned
I have an ImageView on my scene that I would like to set the
I have a ImageView and draw some things on that view. Now I want
I have used ImageView's before and understand the different scale types that can be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.