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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:34:05+00:00 2026-05-27T13:34:05+00:00

I have a relative layout that has an ImageView and and a textview aligned

  • 0

I have a relative layout that has an ImageView and and a textview aligned to right of the ImageView.

I have a class that inflates this relative layout and adds in itself (as if it is that layout).

Initially textview’s visiblity is set to GONE, hence the size of the view is just that of the ImageView.
Now, when the view receives focus, I set the visibility of textview to VISIBLE and set an animation to incrementally resize the view from imageView’s width to (approximately)imageview+textview width (I am actually giving hard coded value in the program).

My question is, how can i determine the total width of the layout after i have enabled/diabled the visibility of the textview(since textview’s width can be variable), so that i can specify that value to the animation as the final endpoint?

I had like to find this out right after i set the visiblity because if there is a delay in enabling the visiblity and starting the animation, the output is like the view with complete width (imageview+textview) is displayed first, then goes back to imageview size(start of animation), and then goes on to imageview+textview size(end of animation).
If these is no way to find it out at that time, then can anyone please suggesst me to manually calculate what the final size could be?

—-EDIT—-

For the effect I wanted to achieve, there didn’t seem to be any way. Final dimension of a view can be computed only after layout for that view is done by Android. The final dimension cannot be computed right after you enable the visiblity of a child view

Hence for my solution, I kept the parent layout (Relative layout) set to fill_parent for the width, had another child layout (background) whose size I could control through program, and then on top of this I have my imageView (Parent Left aligned) + textView (right of imageView, fill_parent).

So when the view is created for the first time, parent layout is always fill_parent, background layout has size of the imageview only and set textview’s visiblity to invisible. And when a text is added to the text view, few milliseconds later (Using countdowntimer), I fetched the final dimension, set the animation to scale the size from imageView’s width to imageView+textView width, and after end of animation set the visiblity of text view to visible.

Am not sure if my solution is the best but it seems to work properly without any glitches.

  • 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-27T13:34:05+00:00Added an answer on May 27, 2026 at 1:34 pm

    If I understood your question right, using getWidth() and getHeight() in the view you want will return the dimensions you seek.

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

Sidebar

Related Questions

I have this layout that works correctly, a relative layout with a text view
I have problems getting some of my views aligned in a relative layout that
I have a Relative Layout. Which has 2 buttons, side by side and it
I have a RelativeLayout , and this Layout has two childs, one is a
Linear layout below. This layout is aligned parent bottom in a Relative Layout. Problem
I have this layout Linear Layout Scroll View Relative Layout 9x Button In View
I have an Activity that inflates an XML FrameLayout that has a custom View,
I have a relative layout and in that I have 4 imageViews stacked one
I have a merge layout that has a few includes in it . I
I have a layout defined through CSS that has three columns. It displays correctly

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.