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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:19:37+00:00 2026-06-07T02:19:37+00:00

I have a Custom ViewGroup with some views inside. In response to an event,

  • 0

I have a Custom ViewGroup with some views inside.

In response to an event, a requestLayout is called and in OnLayout some of the views will
get a new layout position.

One of them maintain its position but needs to be rearranged inside. However this view’s onlayout method will not be called since its layout position doesn’t change. Trying to call requestLayout, forceLayout or invalidate in this view doesn’t work.

The only dirty trick that I have found is to change some of its value position to force the layout change, but I think there should be a better way. So, by now I do something (horrible) like:

    int patch = 0;
    @Override protected void onLayout(boolean changed, int l, int t, int r, int b) {
        ...
        _myView.patchedLayout(patch);
        _myview.layout(l1, t1 , r1, t1+patch);
        patch = (patch+1) % 2;
        ...
    }       

Any way to get the same result in a better way?

  • 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-07T02:19:38+00:00Added an answer on June 7, 2026 at 2:19 am

    I finally got the solution: I need to override onMeasure and be sure to call mesure in my view:

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        ...
        _myview.measure(widthMeasureSpec, heightMeasureSpec);
        ...
    

    It will set the LAYOUT_REQUIRED flag in the view’s private field mPrivateFlags so it will force to call onLayout

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

Sidebar

Related Questions

I have custom event that has several different subscribers who will all use the
I have a problem with my custom ViewGroup. I layout 3 of the children
I have custom validation rule: public function customRule($check) { } Inside this rule I
I have custom gallery. Gallery represents items that are frame layout. There are one
I have custom component that I can place in my layout file (XML) for
I have an Activity with a layout containing a custom ImageView and a few
I have a custom baseadapter which does some lazy loading of some images, and
I have a custom ViewGroup (blue background) that when touched sometime during the app's
I have a custom listView. The main layout xml is something like this: <?xml
Currently, I have a custom list adapter that has some logic that hide/show a

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.