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 9156131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:43:00+00:00 2026-06-17T12:43:00+00:00

I have an Imagebutton and I setColorFilter on ActionDOWN, but if user Slide the

  • 0

I have an Imagebutton and I setColorFilter on ActionDOWN, but if user Slide the finger off the ImageButton, it remains with setColorFilter applied.

Question:

  • How to detect when finger slides off? Then I can apply setColorFilter(null);

    ImageButton i1 = (ImageButton)v.findViewById(R.id.imageButton1);
    i1.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                ImageButton button = (ImageButton)v;
                String principal = "principal";
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    button.setColorFilter(0x8066bbdd);
                    return true;
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    button.setColorFilter(null);
                    Intent i = new Intent(getActivity(), SubView.class);
                    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    i.putExtra("query", principal);
                    startActivity(i);
                    return true;
                }
                return false;
            }
        });
    
  • 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-17T12:43:00+00:00Added an answer on June 17, 2026 at 12:43 pm

    You can use MotionEvent.ACTION_OUTSIDE

    ImageButton i1 = (ImageButton)v.findViewById(R.id.imageButton1); i1.setOnTouchListener(new OnTouchListener() {
    
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            ImageButton button = (ImageButton)v;
            String principal = "principal";
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                button.setColorFilter(0x8066bbdd);
                return true;
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
                button.setColorFilter(null);
                Intent i = new Intent(getActivity(), SubView.class);
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                i.putExtra("query", principal);
                startActivity(i);
                return true;
            } else if(event.getAction() == MotionEvent.ACTION_OUTSIDE)
            {
    
                // Do some stuffs here
            }
    
            return false;
        }
    });
    

    UPDATE 1:

    If MotionEvent.ACTION_OUTSIDE Doesn’t worked you can try MotionEvent.ACTION_CANCEL

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

Sidebar

Related Questions

I have an ImageButton when i press it and keep my finger down it
I have a imagebutton with a image source with transparency, but the background color
I have an ImageButton and I swear I have everything set up right but
I have 6 ImageButton. I applied the same animation to all of them as
I have ImageButton with back arrow in header of my application. When user presses
i'm making a listview ,but scrolling is too slow. i have a ImageButton and
I've have an ImageButton within a ListView . When a user clicks the button
I have a server side ImageButton, and a server side Button, and then a
I have an ImageButton I just added in my layout, but when I call
I have ImageButton with CommandArgument attribute which is having multiple Eval value. When I

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.