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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:52:17+00:00 2026-05-14T03:52:17+00:00

I’m trying to animate a simple ImageView in my application and I want it

  • 0

I’m trying to animate a simple ImageView in my application and I want it to slide in from the bottom of the screen and come to a resting position where the top 50px of the view is off the top of the screen (e.g. the final position of the ImageView should be -50px in X). I’ve tried to use the AbsoluteLayout to do this, but this actually cuts off the top 50px of the ImageView such that the top 50px is never rendered. I need to have the top 50px of the ImageView visible/rendered while it’s animating and then simply have it come to a rest slightly off-screen. I hope I’ve explained that well enough.

Here is what I’m currently using as a layout and the slide-in animation (this currently doesn’t render the top 50px of the ImageView):

Layout:

<?xml version="1.0" encoding="utf-8"?>
   <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent" 
      android:id="@+id/QuickPlayClipLayout">
      <ImageView android:id="@+id/Clip"
         android:background="@drawable/clip" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_y="-50dp">
      </ImageView>
   </AbsoluteLayout>

Animation:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
   <translate android:fromYDelta="100%p" 
       android:toYDelta="0"
       android:duration="1000"/>
   <alpha android:fromAlpha="0.0" 
       android:toAlpha="1.0"
       android:duration="1000" />
</set>
  • 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-14T03:52:17+00:00Added an answer on May 14, 2026 at 3:52 am

    I figured out a solution to this that should be easy to implement. It involves modifying the layout and the Activity inflating the layout… see below:

    Activity (QuickPlay.java):

    public class QuickPlay extends Activity implements AnimationListener
    {
        private ImageView myImageView;
        private LinearLayout LL;
    
        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            this.setContentView(R.layout.quick_play_screen);
    
            myImageView = (ImageView) this.findViewById(R.id.Clip);
            LL = (LinearLayout) this.findViewById(R.id.QuickPlayClipLayout);
    
            //finally
            Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_in_quickplay);
            anim.setAnimationListener(this);
            LL.startAnimation(anim);
        }
        @Override
        public void onAnimationEnd(Animation animation){}
    
        @Override
        public void onAnimationRepeat(Animation animation){}
    
        @Override
        public void onAnimationStart(Animation animation)
        {
            // This is the key...
            //set the coordinates for the bounds (left, top, right, bottom) based on the offset value (50px) in a resource XML
            LL.layout(0, -(int)this.getResources().getDimension(R.dimen.quickplay_offset), 
                    LL.getWidth(), LL.getHeight() + (int)this.getResources().getDimension(R.dimen.quickplay_offset));
        }
    }
    

    New LinearLayout (CustomLinearLayout.java):

    public class CustomLinearLayout extends LinearLayout
    {
        private Context myContext;
    
        public CustomLinearLayout(Context context, AttributeSet attrs) {
            super(context, attrs);
            myContext = context;
        }
    
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
        {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec+((int)myContext.getResources().getDimension(R.dimen.quickplay_offset)));
        }
    }
    

    Layout (/res/layout/quick_play_screen.xml):

    <?xml version="1.0" encoding="utf-8"?>
       <com.games.mygame.CustomLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_height="fill_parent" 
          android:layout_width="fill_parent" 
          android:id="@+id/QuickPlayClipLayout">
          <ImageView android:id="@+id/Clip"
             android:background="@drawable/clip" 
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content">
          </ImageView>
       </com.games.mygame.CustomLinearLayout>
    

    Resource (/res/values/constants.xml):

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <dimen name="quickplay_offset">50dp</dimen>
    </resources>
    

    Animation (/res/anim/slide_in_quickplay.xml):

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
       <translate android:fromYDelta="100%p" 
           android:toYDelta="0"
           android:duration="1000"/>
       <alpha android:fromAlpha="0.0" 
           android:toAlpha="1.0"
           android:duration="1000" />
    </set>
    

    The program now does exactly what I need it to do. The entire layout starts off screen at the bottom, slides in in 1 sec and comes to a rest where the top of the layout is actually 50px off the top of the screen (i.e. LL.getTop() = -50) and the bottom of the layout is resting at the bottom of the screen (i.e. LL.getBottom() = 530 = 480 + 50).

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.