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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:39:40+00:00 2026-06-04T12:39:40+00:00

I tried to start an AlphaAnimation for a ImageView with this code: ImageView view;

  • 0

I tried to start an AlphaAnimation for a ImageView with this code:

        ImageView view;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.prueba);

            view=(ImageView)findViewById(R.id.icon);
            view.setAlpha(0x00);        
            view.setVisibility(View.VISIBLE);
            view.setOnTouchListener(new OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent e) {
                    switch (e.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        Log.i("Down v", "x:" + e.getX() + " y:" + e.getY());
                        view.startAnimation(new AlphaAnimation(0x22, 0xFF));
    //                  break;
                    case MotionEvent.ACTION_MOVE:
                        Log.i("Move", "x:" + e.getX() + " y:" + e.getY());
                        break;
                    case MotionEvent.ACTION_UP:
                        Log.i("Up", "x:" + e.getX() + " y:" + e.getY());
                        view.setAlpha(0x00);
                        break;
                    case MotionEvent.ACTION_OUTSIDE:
                        Log.i("Out", "x:" + e.getX() + " y:" + e.getY());
                        break;
                    default:
                        Log.i("None", "nada");
                    }
                    return false;
                }
            });
            view.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.i("Click", "es un click");
                }
            });
        }

this code should be make the ImageView appear when is touched, but nothing happend.
Any solution?

  • 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-04T12:39:42+00:00Added an answer on June 4, 2026 at 12:39 pm

    This is the odd thing about the Android animations.

    You’re using setAlpha() to set the alpha of the view to 0. At the same time you’re using AlphaAnimation to set the alpha value to 1. This seems like it would work. The problem is they work on two different frameworks. setAlpha() was introduced with Honeycomb in conjunction with ObjectAnimators while AlphaAnimation has been around since Cupcake (possibly API 1 too, but I forget). ObjectAnimators change the actual property of the View while the AlphaAnimation simply changes how the view is drawn (confused yet? :P).

    Anyway, AlphaAnimation doesn’t effect the alpha property of the view like you think it would. It’s animating the View from 0 to 1, but the property is still 0 thus it’s still invisible.

    You have two options here.

    Keep setAlpha() the way it is and use ObjectAnimators like so:

    ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
    anim.setDuration(1000);
    anim.start();
    

    This is the easiest and preferred method. It only works in API levels 11+ though. If that’s desired, then go for it.

    The other option is to remove setAlpha() and pre-animate the view to 0 with a duration of 0. Call setFillAfter(true) on the animation before you start it. This will make sure it stays invisible (it may be true by default, but I don’t remember).

    I hope that made sense.

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

Sidebar

Related Questions

can anyone tell me why this animation isn't starting? i've tried putting code in
I tried to start Visual Studio and it said: This application has failed to
I tried exim4 start , but now I get this error: lookup type mysql
I've tried this: 'start Excel app Dim exApp As Microsoft.Office.Interop.Excel.Application exApp = CreateObject(Excel.Application) '
I've tried to start the rails server with this line: $ rails s create
After trying to figure out why a Capistrano task (which tried to start a
i run nexus-2.0.2 on linux, following nexus referrence, i tried to start up nexus,
I tried the following DateTime start = Convert.ToDateTime(TextBox1.Text); DateTime end = Convert.ToDateTime(TextBox2.Text); if (DateTime.Now.Date
I've tried getting the launch link from the start menu and using Process.Start() But
I've tried '--kiosk', '--start-maximized'; but all not work, any solution yet? Further, the web

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.