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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:04:29+00:00 2026-05-18T10:04:29+00:00

Imagine a full Android device screen, I want it split in to two sections:

  • 0

Imagine a full Android device screen, I want it split in to two sections:

  1. The upper half has text in it, which may be larger than the space available (or not) and so the text will scroll (i.e. TextView inside a ScrollView)
  2. The lower half contains a MapView control.

Looking specifically at some scenarios:

  1. If the text is small, I want the map to take up more space, i.e. more than 50%. So perhaps 20% text, 80% map.
  2. If the text is larger, it only takes up a MAXIMUM of 50% of the screen space, and then scrolls. So 50% map, 50% text.

At the moment I’ve assigned weights to the two parts, and that isn’t too bad, but if the text is small, the map doesn’t expand to take the space, and the layout has a wasted gap that the map could usefully use.

I’ve tried loads of combinations but can’t see how to make this happen. It seems to be a common experience for me that I know what I want, but can’t see how to get the available views to deliver it. I’m hoping there’s a nice easy way to do this.

Please feel free to make me look like a fool and point out the obvious attribute I’ve missed 🙂

======================================================================

As far as I can see there’s no way to do this just in declarative XML and it needs doing in the code. I set the text section height to wrap_content, weight to 0 (no resizing), and have the map set to weight=1 (i.e. take up the remaining space). I then check if the text section (in a ScrollView) is taking up too much space and if so, shrink it back. This code would need changing to support a different layout orientation.

private void fixLayoutProportions()
{
    float maxPercentageOfScreenForText = 50/100;
    LinearLayout container = (LinearLayout)findViewById(R.id.container);
    ScrollView eventText = (ScrollView)findViewById(R.id.text_scroller);
    int heightAvailable = container.getHeight();
    int scrollerHeight = eventText.getHeight();
    if ( scrollerHeight>(heightAvailable*maxPercentageOfScreenForText) )      // Text section using too much space
    {
        eventText.getLayoutParams().height = (int)(heightAvailable*maxPercentageOfScreenForText) ;
        eventText.invalidate();
    }
}
  • 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-18T10:04:29+00:00Added an answer on May 18, 2026 at 10:04 am

    Did you try to measure your screen hight at run time:

    Display display = ((WindowManager) 
          getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
    int width = display.getHeight();
    

    Then, set your top view max_height to width*0.5 and min_height to width*0.2. Your top view has to be control (like TextView) that has min_height and max_height properties. Also, set layout_weight to 0 or leave it empty.
    On your bottom view set layout weight to 1.

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

Sidebar

Related Questions

I just want to ask a simple question related the GLSurfaceView and drawn objects
Imagine you've got a big SVN tree with branches all over the place. There
So imagine we have TCP server recieving all browser requests. How a cookie generated
Possible Duplicate: LINQ list to sentence format (insert commas & “and”) Imagine these inputs
hey guys, i'm working on a concept for university. i wonder what's the easiest
My Problem: Linked to my Employees table I've got an Address table containing a
I'm hoping this will be relatively easy to someone who is familiar with the
Having a heck of a time with this; I'm convinced I'm just not getting
This query works: SELECT u.UserId, u.GroupId, u.username, gp.PreferenceId, gp.Properties, gp.Override FROM dbo.UserTable u Inner

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.