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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:38:40+00:00 2026-05-17T17:38:40+00:00

I’m finding the need to lay out a fairly complex UI manually, by giving

  • 0

I’m finding the need to lay out a fairly complex UI manually, by giving the dimensions and position of most all of the sub views. My plan is to code the XML initially for a 480×320 display, get it all working right to demo for the client on a given device, then modify it for production by programmatically adjusting the size and position of the views to adapt it to whatever screen size it’s running on.

First…I know this is not the recommended approach. I have spent forever trying to get the automated layouts to work right (along with animations). Honestly I don’t think they were made for the way the client wants this, and I just don’t have any more time to mess around with it. (nor to learn to make a flexible custom layout)

Given that, where should I do the measuring/positioning? I can do onMeasure() to set the sizes (ignoring the incoming parameters and basing them instead on my knowledge of the screen resolution which is measure when the Activity starts), but where do I set the position of each the view? In onLayout()? Assume all views will be subclasses anyway (as opposed to using components out of the box)

Ideally, I’d like to have one place where I measure the screen res, then grab each view and set its x, y, width and height. Is that possible? If so how?

Edit: now offering a bounty. Note that I also did a sketch of one simple problem I’m trying to solve — http://karmalita.com/stuff/layout.png — which if you can do it the “correct” way (say, using a relative layout), the bounty is yours.

  • 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-17T17:38:41+00:00Added an answer on May 17, 2026 at 5:38 pm

    From your diagram, the basic structure could be something like the following. Not generally you wouldn’t specify absolute values like “50dp” for layout widths and heights, instead relying on the views to report their desired size. For example, if your top bar is a 9-patch border with text inside, you could just make this a TextView where you specify the text and set the 9-patch with android:background=”@drawable/…”, and let the text view compute its appropriate width and height based on the text size and padding of the 9-patch. (And than use match_parent to ignore that size and allow it to stretch to fill its parent, or wrap_content to use its desired size.)

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
      <View
          android:layout_width="match_parent"
          android:layout_height="50dp" />
      <View
          android:layout_width="match_parent"
          android:layout_height="0px"
          android:layout_weight="1" />
      <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal">
          <View
              android:layout_width="??dp"
              android:layout_height="55dp" />
          ...
      </LinearLayout>
      <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal">
          <View
              android:layout_width="??dp"
              android:layout_height="60dp" />
          ...
      </LinearLayout>
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

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.