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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:47:09+00:00 2026-05-24T10:47:09+00:00

I do have a layout that contains a WebView and a Gallery on top.

  • 0

I do have a layout that contains a WebView and a Gallery on top. I would like to give the Gallery 20% of the screen always. The WebView should occupy the 80% always.

Usually this works with layout_weight in all my layouts where the higher value is the smaller view and 1 is the biggest view. In this layout it is completely different. Here I need to use a higher value for the bigger element and it doesn’t stay at fixed ratio.

Any help is highly appreciated.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:orientation="vertical" >

    <Gallery 
        android:id="@+id/gallery"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:spacing="2dip" />       

    <View
        android:background="@android:color/white"
        android:layout_height="1dip"
        android:layout_marginTop="6dip"
        android:layout_width="fill_parent" />

    <WebView
        android:id="@+id/webview"
        android:layout_height="wrap_content"
        android:layout_weight="5"
        android:layout_width="fill_parent" />
</LinearLayout>
  • 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-24T10:47:09+00:00Added an answer on May 24, 2026 at 10:47 am

    Weight is used to distribute the extra space AFTER taking into account any height/width values set. For a vertical LinearLayout, if you want to ensure a 20/80 ratio (ignoring the separator), you should set a height of zero (doesn’t matter which unit) for the components. Otherwise, Android will take into account their height first and only distribute the remaining space in the ratio of the weights.

    As an example, consider having a (horizontal LinearLayout) container with width 100 pixels, and two components both with weights 1, but with widths set to 10 pixels and 30 pixels respectively. To calculate their sizes we first subtract the widths from the container size: 100 – 10 – 30 = 60. Then we divide it up in the ratio of weights: 60 / (1+1) = 30, and distribute each part accordingly. The first view will have width 10+30 = 40, while the second view will have width 30+30 = 60, even though they had the same weight.

    Try the following layout:

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:orientation="vertical" >
    
    <Gallery 
        android:id="@+id/gallery"
        android:layout_height="0px"
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:spacing="2dip" />       
    
    <View
        android:background="@android:color/white"
        android:layout_height="1dip"
        android:layout_marginTop="6dip"
        android:layout_width="fill_parent" />
    
    <WebView
        android:id="@+id/webview"
        android:layout_height="0px"
        android:layout_weight="5"
        android:layout_width="fill_parent" />
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have a layout that contains a gallery a textview with .setEllipsize(TruncateAt.MARQUEE); They
I have Tab Layout that contains a TextView. I'd like to assign some text
I have a layout that contains several sub-views all which set height like: <View
I have a basic website nav layout that looks like this: <li class=folder parent_folder>
I have a UI layout that's comprised of a single outer layout that contains
I have an Activity whose layout is in the file main.xml that contains a
I have a linear layout that contains 6 images, which span the linear layout
I have a layout that contains a TableLayout with three rows. Each row has
I have an Android app that I would like to convert to an Android
I have created a layout that contains two buttons, Next and Previous. In between

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.