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

  • Home
  • SEARCH
  • 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 5988651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:59:17+00:00 2026-05-22T22:59:17+00:00

This should be fairly simple, but it is turning out to be more complicated

  • 0

This should be fairly simple, but it is turning out to be more complicated than I thought. How can I apply a ScaleAnimation to a view and get it to stay for the entire duration of a finger press? In other words, while he finger is down shrink the view until the finger is removed, then return it to its original size?
This is what I have tried:

public void onTouch(View v, MotionEvent event)
{
    switch(event.getAction())
    {
    case MotionEvent.ACTION_DOWN
    {
        v.setAnimation(shrinkAnim);
    }
    case MotionEvent.ACTION_UP
    {
        v.setAnimation(growAnim);
    }
    }
}

If I apply setFillEnabled(true) and setFillAfter(true) then the shrink stays indefinitely. If I don’t use it it shrinks for a second then goes back to normal. Thanks ahead of time

  • 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-05-22T22:59:18+00:00Added an answer on May 22, 2026 at 10:59 pm

    It’s a bit unclear what you have and haven’t tried in what combination, so here’s an example that works:

    Animation shrink, grow;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        //I chose onCreate(), but make the animations however suits you.
        //The animations need only be created once.
    
        //From 100% to 70% about center
        shrink = new ScaleAnimation(1.0f, 0.7f, 1.0f, 0.7f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF,0.5f);
        shrink.setDuration(200);
        shrink.setFillAfter(true);
    
        //From 70% to 100% about center
        grow = new ScaleAnimation(0.7f, 1.0f, 0.7f, 1.0f, ScaleAnimation.RELATIVE_TO_SELF,0.5f,ScaleAnimation.RELATIVE_TO_SELF,0.5f);
        grow.setDuration(200);
        grow.setFillAfter(true);
    }
    
    @Override
    public void onTouch(View v, MotionEvent event) {
        switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            v.startAnimation(shrink);
            break;
        case MotionEvent.ACTION_UP:
            v.startAnimation(grow);
            break;
        default:
            break;
        }
    }
    

    The animations should be defined once and reused, with their setFillAfter(true) parameter set; this makes the drawing stick in the final position. When you apply the animations to the view use startAnimation(), setAnimation() is designed for animations that manage their own start times.

    Hope that Helps!

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

Sidebar

Related Questions

This should be fairly simple from what I can find online, but I can't
This seems like it should be fairly simple, but for some reason I can't
This should be fairly simple, but I just can't see the logic in it!
I know this should be fairly simple but I don't get it anyhow. I've
This should be a fairly simple question but I know very little about SQL.
It feels like this should be fairly simple but nothing i've tried so far
This should be a really really simple thing, but for some reason it is
This should be a simple question, but I haven't been able to find a
This should be fairly simple question. I'm using DocX library to create new word
Seems like it should be fairly simple but I'm having trouble excluding folders when

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.