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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:50:25+00:00 2026-06-17T04:50:25+00:00

I have an ImageButton when i press it and keep my finger down it

  • 0

I have an ImageButton when i press it and keep my finger down it becomes invisible, when i lift my finger it becomes visible again.

But when i press the button and while my finger is down i move it away from it and lift it up it doesn’t become visible again

The code looks like this

final ImageButton b=(ImageButton)findViewById(R.id.timer_btn);

        b.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {

                  case MotionEvent.ACTION_UP: 
                        b.setVisibility(View.VISIBLE);
                        Log.w("app", "Action up");
                        return true;
                  case MotionEvent.ACTION_DOWN: 
                        b.setVisibility(View.INVISIBLE);
                        Log.w("app", "Action down");

                       }
                    return false;
            }
        });

I tried using

case MotionEvent.ACTION_OUTSIDE: 
                            b.setVisibility(View.VISIBLE);
                            Log.w("app", "Action outside");

                           }

but it doesn’t work, it gets called no matter if it’s outside the button or inside

  • 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-17T04:50:26+00:00Added an answer on June 17, 2026 at 4:50 am

    you have to use the ACTION_CANCEL.
    I guess the ACTION_OUSIDE is for outside the actual screen.

    The system will always calls either the UP or the CANCEL.

    edit:

    I believe this should work:

                  case MotionEvent.ACTION_CANCEL: 
                  case MotionEvent.ACTION_UP: 
                        b.setVisibility(View.VISIBLE);
                        Log.w("app", "Action up");
                        return true;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Imagebutton and I setColorFilter on ActionDOWN, but if user Slide the
I have a imagebutton with a image source with transparency, but the background color
i have a ImageButton, and i need to mantain the status of the button
I have asp:ImageButton in asp:table. I want to get the id of button in
I have 3 activities. 1st activity has a 'go right' image button. (to move
I have a Image button defined as follow, <div> <asp:ImageButton ID=btn1 runat=server ImageUrl=/_LAYOUTS/1033/IMAGES/row.png />
I have one imageButton. When I clicked on ImageButton. It makes VISIBLE another layout(childLayout)
I have an ImageButton and want to scale the button in different sizes which
While creating a custom Viewgroup,is it possible to have multiple Imagebutton within it? is
I have a button - on press of that , i am playing a

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.