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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:35:20+00:00 2026-06-02T03:35:20+00:00

Can I somehow prevent calling the Layout method of all Children if I only

  • 0

Can I somehow prevent calling the Layout method of all Children if I only want to set the layout for the parent view and still want to keep the layout settings of the children?

Currently I call parent.layout() and all its children get a width and heiht of zero. Can’t I somehow set the children to FillParent istead of setting the layout to ALL ? 🙁

By the way, my parent is an extended LinearLayout containing mostly Textviews.

Edit:
Some code:

myLayout extends LinearLayout

myLayout.layout(left, top, right, bottom);                
myLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1));

for each child in myLayout do {
  child.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  if (v instanceof TextView) {
    ((TextView) v).setGravity(Gravity.CENTER);
  }

But child still has:
left: 0 top: 0 right: 0 bottom: 0

Edit 2:
By the way: the code above is insider the onLayout method of a ViewGroup.

  • 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-02T03:35:22+00:00Added an answer on June 2, 2026 at 3:35 am

    Your child views aren’t getting measured (since you don’t call their layout()), so the system still thinks that they are 0x0px.

    Android uses a 2-pass system of measure/layout.

    Check out the developer docs to see how the drawing/layout sequence happens: http://developer.android.com/guide/topics/ui/how-android-draws.html

    You might want to try calling their layout(), then setting the height/width on the children, then calling requestLayout().

    Hope that helps.

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

Sidebar

Related Questions

Can you somehow lock an iPad to Safari and only one webpage? I've found
I've been working all day and I somehow can't get this probably easy task
Problem I want to create an application that can be extended somehow by programmers.
Can I somehow disable ListView items navigation through keyboard (arrow keys), and leave navigation
Can I somehow automatically add a node to a specific nodequeue when it is
Can anyone tell me, if in PostSharp, I somehow can turn on/off tracing in
looper = (0..3).cycle 20.times { puts looper.next } can I somehow find the next
I would like to avoid the if statement below. Can I somehow copy the
Can I get somehow(from a database or other source) a percentage of the phones
This is something I know can be done somehow , because I've done it

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.