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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:50:08+00:00 2026-06-05T14:50:08+00:00

It appears that the old view animations ( translate , scale , and so

  • 0

It appears that the old view animations (translate, scale, and so on) are no longer accepted by the AnimationInflater, at least as of ICS. I read its code in 4.0.4, and it explicitly expects only the XML elements set, objectAnimator, animator.

Even though the documentation at http://developer.android.com/guide/topics/resources/animation-resource.html continues to include the view animations, they appear to be deprecated. Trying to use them results in, for instance, the error java.lang.RuntimeException: Unknown animator name: translate.

As such, it becomes necessary to use Android’s ObjectAnimator. However, it does not accept fractional values of the associated dimension of itself or its parent (width for translationX, for example) as the old view animations did in the form "75%p".

Constructing the ObjectAnimator manually at runtime, by programmatically fetching the size of the Fragment, isn’t feasible because the FragmentTransaction only accepts declarative animations specified by a resid.

My goal is to translate offscreen a Fragment that is filling up an entire Activity (I’m basically doing a shift transition between two fragments). This is the existing TranslationAnimation implementation (slide_in_right.xml, which along with its counterpart slide_out_left.xml is for some reason not exposed in android.R.anim, and I therefore have to duplicate them in my codebase):

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
    android:fromXDelta="100%p"
    android:toXDelta="0"
    android:duration="@android:integer/config_mediumAnimTime"/>
</set>

My API level is set to 14.

Thanks!

  • 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-05T14:50:11+00:00Added an answer on June 5, 2026 at 2:50 pm

    Actually object animators accept fractional values. But maybe you didn’t understand the underlying concept of an objectAnimator or more generally a value animator. A value animator will animate a value related to a property (such as a color, a position on screen (X,Y), an alpha parameter or whatever you want). To create such a property (in your case xFraction and yFraction) you need to build your own getters and setters associated to this property name. Lets say you want to translate a FrameLayout from 0% to 25% of the size of your whole screen. Then you need to build a custom View that wraps the FrameLayout objects and write your getters and setters.

    public class SlidingFrameLayout extends FrameLayout
    {
        private static final String TAG = SlidingFrameLayout.class.getName();
    
        public SlidingFrameLayout(Context context) {
            super(context);
        }
    
        public SlidingFrameLayout(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public float getXFraction()
        {
            int width = getWindowManager().getDefaultDisplay().getWidth();
            return (width == 0) ? 0 : getX() / (float) width;
        }
    
        public void setXFraction(float xFraction) {
            int width = getWindowManager().getDefaultDisplay().getWidth();
            setX((width > 0) ? (xFraction * width) : 0);
        }
    }
    

    Then You can use the xml way to declare the object animator putting xFraction under the property xml attribute and inflate it with a AnimatorInflater

    <?xml version="1.0" encoding="utf-8"?>
    <objectAnimator 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:propertyName="xFraction" 
    android:valueType="floatType"
    android:valueFrom="0"
    android:valueTo="0.25" 
    android:duration="500"/>
    

    or you can just use the java line code

    ObjectAnimator oa = ObjectAnimator.ofFloat(menuFragmentContainer, "xFraction", 0, 0.25f);
    

    Hope it helps you!

    Olivier,

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

Sidebar

Related Questions

The project that I've been working on involves porting some old code. Right now
I've got a lot of older code that uses the old-style pascal object type
I have a client running an old version of magento. It appears that there
I've opened an old workspace that is a library and its test harness. It
Appears that WAS does not support the integration binding. I've tried setting it up
It appears that NetBeans and Aptana/RadRails are the most common adopted IDE's for Ruby
It appears that the simplest, naivest way to do basic sentiment analysis is with
it appears that the Apple site now only provides download for Xcode 3.2, that
It appears that we will have to build/deploy one of our new JBoss apps
It appears that calling Html.RenderAction in Asp.Net MVC2 apps can alter the mime type

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.