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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:12:31+00:00 2026-06-11T00:12:31+00:00

I have a problem. I want to animate the background color of a LinearLayout

  • 0

I have a problem. I want to animate the background color of a LinearLayout, using ObjectAnimator.
The problem is that it animates, but it does neither care about duration nor valueFrom and valueTo.

This is my xml file:

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2000"
    android:propertyName="backgroundColor"
    android:repeatCount="infinite"
    android:repeatMode="reverse"
    android:valueFrom="#FF0000"
    android:valueTo="#000000" />

In Java I call like this:

ObjectAnimator objAnim = (ObjectAnimator)AnimatorInflater.loadAnimator(getActivity(), R.animator.animator_bkg);
objAnim.setTarget(view);
objAnim.start();

Note that when I animate the alpha of the layout, it works as expected.
Is this an Android bug (4.0.3 on Asus Transformer), or I miss something?

  • 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-11T00:12:32+00:00Added an answer on June 11, 2026 at 12:12 am

    I googled a bit. There is an answer. Try to use TransitionDrawable. http://developer.android.com/guide/topics/resources/drawable-resource.html#Transition

    Also, there is a topic somewhere on stackoverflow.com dedicated to the same problem.

    ADDED Code example:

        Button btn = (Button)this.findViewById(R.id.btn1);
        //Let's change background's color from blue to red.
        ColorDrawable[] color = {new ColorDrawable(Color.BLUE), new ColorDrawable(Color.RED)};
        TransitionDrawable trans = new TransitionDrawable(color);
        //This will work also on old devices. The latest API says you have to use setBackground instead.
        btn.setBackgroundDrawable(trans);
        trans.startTransition(5000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to use .animate function but i have some problems i want to
I am using GWT/JAVA for development. I have following problem: I want to remove
I have a problem when I want to sending data using byte format in
I have problem with fancybox. I want to write a function that will run
I want to place UItextField in UITableViewCell but I have problem. Text field don't
I have a problem with animate loop. There is an object i want to
My problem is: I have a drop down menu and i want that when
I have an element in my document that has a background color and image
i want to animate my scrollLeft = value using XUI (note that I can't
All, I have a Task that runs on a background thread and does some

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.