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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:55:54+00:00 2026-05-17T16:55:54+00:00

One part of my layout is supposed to have two components: A ScrollView on

  • 0

One part of my layout is supposed to have two components: A ScrollView on top, and a MapView on the bottom. Both views should be exactly half the size of the parent.

I have the size of the parent (I’m switching to this layout at a point when I already have the size), but I don’t know how to define the maximum size. Besides, I figure there is a solution that doesn’t require defining the size; for example by having something like a Swing-style GridLayout, or defining a weight somewhere, but I haven’t found anything that sounds like it would work.

My current approach is this here, which defines the minimum size, which obviously falls apart as soon as the ScrollView grows beyond half the height of the parent:

The layout (the parent is a LinearLayout):

<LinearLayout
    android:id="@+id/result_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:visibility="gone"
    >

<ScrollView
    android:id="@+id/result_scroll"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    >

<LinearLayout
    android:id="@+id/result"
    android:layout_height="fill_parent"
    android:layout_width="wrap_content"
    android:paddingRight="?android:attr/scrollbarSize"
    android:orientation="vertical"
/>

</ScrollView>

<view class="com.google.android.maps.MapView"
    android:id="@+id/mapview"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
  />

</LinearLayout>

And the code, after I switch to it (totalWidth being the width of the parent, viewHeight half the height of the parent):

LinearLayout.LayoutParams lp =
            new LinearLayout.LayoutParams(totalWidth, viewHeight);
scrollView.setLayoutParams(lp);
  • 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-17T16:55:55+00:00Added an answer on May 17, 2026 at 4:55 pm

    One part of my layout is supposed to have two components: A ScrollView on top, and a MapView on the bottom. Both views should be exactly half the size of the parent.

    Put them in a LinearLayout. Set the the height of each to 0px. Set the weight of each to 1.

    For example:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent">
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="0px"
        android:layout_weight="1"/>
    <Button
        android:layout_width="fill_parent"
        android:layout_height="0px"
        android:layout_weight="1"/>
    </LinearLayout> 
    

    Besides, I figure there is a solution that doesn’t require defining the size…or defining a weight somewhere

    If you don’t tell it how big it is explicitly (“defining the size”) or implicitly (“defining a weight”), how are you expecting to know it is supposed to be “exactly half the size of the parent”?

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

Sidebar

Related Questions

So let's say I have two different functions. One is a part of the
Should libraries that the application relies on be stored in source control? One part
I have an OpenGL ES game that I am hacking together. One part of
I have a site in rails and want to have site-wide settings. One part
I have an application that I have to run as Administrator. One small part
I'm really struggling with a part of layout in my app. I have a
Part 1: I have a call to layout(:default){|path,wish| wish !~ /rss|atom|json/} but requests to
As the title really, I'm in one part of my code and I would
I'm working with some example java code for making md5 hashes. One part converts
Our project has one folder that is not part of the solution. How can

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.