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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:15:33+00:00 2026-06-17T01:15:33+00:00

I have a Linear Layout with 2 buttons of equal weights. So they occupy

  • 0

I have a Linear Layout with 2 buttons of equal weights. So they occupy the whole screen(width wise).

In another Linear Layout below the 1st, i only have 1 button, whose width i want to be same as any 1 of the previous 2 buttons.

Is there a simple way to do, other than using gridview or tableview etc..,

I tried this:

Button one = (Button) findViewById(R.id.one);
Button two = (Button) findViewById(R.id.two);
Button three = (Button) findViewById(R.id.three);

three.setLayoutParams(new LinearLayout.LayoutParams(
        one.getLayoutParams()));

Layout:

<LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/first"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

        <Button
            android:id="@+id/one"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

        <Button
            android:id="@+id/two"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />
    </LinearLayout>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/second"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/first"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/three"
            android:layout_width="150dp"
            android:layout_height="wrap_content" />
    </LinearLayout>

But the 3rd Button is invisible now.

Thank You

  • 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-17T01:15:34+00:00Added an answer on June 17, 2026 at 1:15 am

    try this for second row

    <LinearLayout
        android:id="@+id/second"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/first1"
        android:weightSum="2"
        android:orientation="horizontal" >
    
        <Button
            android:layout_weight="1"
            android:id="@+id/three"
            android:layout_width="0dp"
            android:layout_height="wrap_content" />
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a linear layout with several buttons in it. The button images are
I have 4 buttons in a horizontal linear layout. I'd like the right edge
I have three buttons in my Actvity inside Linear Layout. Here i wish all
I have a linear linear layout with 10 buttons in it. I need to
I have a linear layout with two listviews and two dead buttons. How to
i have bunch of buttons within linear layout. But there is spaces buttons. I
I have a horizontal linear layout with four image buttons. Each image button has
Ok, i have two buttons in linear layout: <LinearLayout android:id=@+id/linearLayout1 android:layout_height=wrap_content android:layout_width=fill_parent> <Button android:id=@+id/aktiviraj_paket
I'm trying to add custom buttons to my XML I have a linear layout
I have following three button in a Linear Layout with width fill_parent . How

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.