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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:22:29+00:00 2026-06-15T08:22:29+00:00

In my LinearLayout I have two child ViewGroups, basically I want them to take

  • 0

In my LinearLayout I have two child ViewGroups, basically I want them to take 50% of space each (and it is done), but there is also a possibility that content of one of these ViewGroups is much smaller than 50%, in this case, is there any way to make second view match the remaining space?

Now my layout looks like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5dp"
    android:paddingBottom="5dp"
    android:orientation="horizontal"
    android:weightSum="1">

<include layout="@layout/layout1"
    android:layout_width="0dip"
    android:layout_weight="0.5"
    android:layout_height="match_parent" />

<include layout="@layout/layout2"
    android:layout_width="0dip"
    android:layout_weight="0.5"
    android:layout_height="match_parent" />

And what I want to achieve is: one layout wrap_content, but no more than 50%, and the second layout fill remaining space.

Thanks in advance!

  • 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-15T08:22:29+00:00Added an answer on June 15, 2026 at 8:22 am

    Make two layouts inside of your linear layouts,and give each of these a layout_weight of 0.5. Then in each of these put a your view groups with the trait android:layout_width="wrap_content". As such –

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5dp"
    android:paddingBottom="5dp"
    android:orientation="horizontal"
    android:weightSum="1">
        <LinearLayout
           android:layout_weight="0.5"
           ......
    <include layout="@layout/layout1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />
    </LinearLayout>
    <LinearLayout
         android:layout_weight="0.5"
         ......
    <include layout="@layout/layout2"
        android:layout_width="0dip"
        android:layout_weight="0.5"
        android:layout_height="match_parent" />
    <LinearLayout/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two textviews. I want one of them to be left aligned and
I have two views that take the whole screen and I want to display
I have a LinearLayout , mRoot , and it has two child of TextView
I have a LinearLayout and I want to see when a user has touched
I have a LinearLayout and its child - ImageView. My activity's onCreate does nothing
I have a simple vertical LinearLayout in which there is a button on the
Basically, I have two classes : - MyActivity.java - OtherClass.java Overview of MyActivity.java :
In my project I need use custom Dialog instead AlertDialog. But I have two
I have a complex layout situation in which an horizontal LinearLayout holds two other
Let's say in a LinearLayout we have two EditText. Android system is somehow able

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.