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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:27:16+00:00 2026-06-09T17:27:16+00:00

I’ve looked through so many threads here trying to understand why this is happening,

  • 0

I’ve looked through so many threads here trying to understand why this is happening, but I just cannot wrap my head around it.

In my RelativeLayout I have 4 HorizontalScrollViews (HSV) that lay above a menu (which is alignedParentBottom).

I want to evenly space the 4 HSVs above this menu.

By my calculations, I should be able to take the device height, subtract the menu height, and then divide by 4, to get an individual HSV height.

However, when I set the height of each HSV, they are larger than they should be.

(note: display.getHeight() returns the correct dimension. I am on a 480×800 device, and if I print deviceHeight it returns 800)

Here is my code:

    RelativeLayout menuLayout = (RelativeLayout)findViewById(R.id.menuLayout);
    HorizontalScrollView row1 = (HorizontalScrollView)findViewById(R.id.row1);
    HorizontalScrollView row2 = (HorizontalScrollView)findViewById(R.id.row2);
    HorizontalScrollView row3 = (HorizontalScrollView)findViewById(R.id.row3);
    HorizontalScrollView row4 = (HorizontalScrollView)findViewById(R.id.row4);

    //get current device dimensions
    Display display = getWindowManager().getDefaultDisplay();
    deviceWidth = display.getWidth(); //returns 480
    deviceHeight = display.getHeight(); //returns 800

    int menuHeight = deviceWidth/5; // 480/5 = 96
    int remainingSpace = deviceHeight - menuHeight; // 800 - 96 = 704
    int rowHeight = (int) (remainingSpace/4); // 704/4 = 176

    menuLayout.getLayoutParams().height = menuHeight;

    row1.getLayoutParams().height = rowHeight;
    row2.getLayoutParams().height = rowHeight;
    row3.getLayoutParams().height = rowHeight;
    row4.getLayoutParams().height = rowHeight;

When I run this code, each row is too large, and gets pushed under the menu at the bottom. If I run getHeight(). on a row, it says it is the correct height (176), but clearly it is not (as the 4 rows are too large to fit in the space above the menu).

Can anyone shed a light on this? Thank you so much!

  • 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-09T17:27:17+00:00Added an answer on June 9, 2026 at 5:27 pm

    I wasn’t considering that there is the menu bar at the top, which takes up part of the devices screen. My solution is to have the main layout height be fill_parent, and then to get the height of the main layout. I use this value, instead of the display.getHeight() value.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.