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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:04:00+00:00 2026-05-21T21:04:00+00:00

I’m running into a problem that has me stumped and I was hoping someone

  • 0

I’m running into a problem that has me stumped and I was hoping someone could give me some pointers.

I’m working on an application that uses a custom ViewGroup (actually a FrameLayout that contains a RelativeLayout) to render an event calendar. The events inside the calendar are represented as views that are sized according to the duration of the event and the size of the containing view.

I’m running into a problem that occurs when the containing FrameLayout is resized. The current implementation removes all of the views that represent the events and attempts to add new ones and calculate their sizes based on the current size of the FrameLayout. This work is being triggered via the onSizeChanged() method of View which is overridden in the FrameLayout.

When the view is resized, this code is executed and the views are updated, however, none of them actually render on the screen… the views contained within the FrameLayout are simply not visible. If I load the view in the hierarchyviewer tool, they are part of the view tree, and are outlined in the overview in the positions they should be in, but they do not display. (Note that the views are visible on the initial render of the FrameLayout… it’s only after a resize that they disappear.)

It appears that the order of events during the resize is as follows:

onMeasure()
onMeasure()
onSizeChanged()
onLayout()

Calling requestLayout() after resetting the views (inside onSizeChanged()) seems to have no effect. However, if I cause some delay before calling requestLayout(), the views become visible. I can cause this delay by spawning a thread and sleeping, or by creating a dummy button that simply calls requestLayout() and pressing it after the resize myself, or even this ugly hack placed at the end of onSizeChanged():

post(new Runnable() {
    public void run() {
        requestLayout();
    }
});

When I use this hack, the contained views are visible, and the order of events is as follows:

onMeasure()
onMeasure()
onSizeChanged()
onLayout()
onMeasure()
onMeasure()
onLayout()

So it appears that forcing a second measure pass (after the view tree has been modified) makes the contained views visible as they should be. Why delaying the call to requestLayout() does this is a mystery to me.

Can anyone provide any pointers as to what I’m doing wrong?

I realize that this is somewhat difficult to follow without looking at some code, so I have created a small sample application that exhibits my issue and made it available on Github:

https://github.com/MichaelSims/ViewGroupResizeTest

The hack I mentioned above is committed to a separate branch:

https://github.com/MichaelSims/ViewGroupResizeTest/tree/post-runnable-hack

If I can provide any additional information, please let me know and thanks in advance.

  • 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-21T21:04:01+00:00Added an answer on May 21, 2026 at 9:04 pm

    It’s not a hack, it’s how it’s supposed to work. onSizeChanged() is invoked as part of the layout pass, and you cannot/should not requestLayout() during a layout pass. It is correct to post a requestLayout() on the event queue to indicate that you have changed the View hierarchy during a layout pass.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.