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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:56:59+00:00 2026-05-26T20:56:59+00:00

I want to resize some layouts in my Activity. Here is the code of

  • 0

I want to resize some layouts in my Activity.

Here is the code of the main XML:

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/top"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:background="#3ee3e3" >
    </LinearLayout>

    <LinearLayout
        android:id="@+id/middle"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">
    </LinearLayout>

    <LinearLayout
        android:id="@+id/bottom"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:background="#fe51e6" >
    </LinearLayout>
</LinearLayout>

As you can see, the top and bottom layouts height’s is 0, and the middle
layout covers all the place.

I want to programmatically decrease the middle layout size, while increase both the top
and the bottom layout sizes, till all the layouts have the same height.

I want it to be look like an animation.

How should I do that?

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-05-26T20:57:00+00:00Added an answer on May 26, 2026 at 8:57 pm

    I wrote a ResizeAnimation for a similar purpose. It’s simple but costly.

    Java

        /**
         * an animation for resizing the view.
         */
        public class ResizeAnimation extends Animation {
            private View mView;
            private float mToHeight;
            private float mFromHeight;
    
            private float mToWidth;
            private float mFromWidth;
    
            public ResizeAnimation(View v, float fromWidth, float fromHeight, float toWidth, float toHeight) {
                mToHeight = toHeight;
                mToWidth = toWidth;
                mFromHeight = fromHeight;
                mFromWidth = fromWidth;
                mView = v;
                setDuration(300);
            }
    
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                float height =
                        (mToHeight - mFromHeight) * interpolatedTime + mFromHeight;
                float width = (mToWidth - mFromWidth) * interpolatedTime + mFromWidth;
                LayoutParams p = mView.getLayoutParams();
                p.height = (int) height;
                p.width = (int) width;
                mView.requestLayout();
            }
        }
    

    Kotlin

    class ResizeAnimation(
        private val view: View,
        private val toHeight: Float,
        private val fromHeight: Float,
        private val toWidth: Float,
        private val fromWidth: Float,
        duration: Long
    ) : Animation() {
    
        init {
            this.duration = duration
        }
    
        override fun applyTransformation(
            interpolatedTime: Float,
            t: Transformation?
        ) {
            val height = (toHeight - fromHeight) * interpolatedTime + fromHeight
            val width = (toWidth - fromWidth) * interpolatedTime + fromWidth
            val layoutParams = view.layoutParams
            layoutParams.height = height.toInt()
            layoutParams.width = width.toInt()
            view.requestLayout()
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to resize some game window (DirectX) after it has been created, the
I have the following code that I use to resize some images on my
I am using android ImageButton, I want to resize the image so that it
I have a main container div that I want to resize dynamically. In a
I want to resize the font of a SPAN element's style until it the
I want to resize cell's height according to the label's height and label's height
i want to resize the font of all elements of a page like user
I have an image that I want to resize on my websites rendering using
I have an image . I want to resize it using PIL, but it
Let's consider we have QWidget that contains QTableWidget (only). So we want to resize

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.