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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:57:45+00:00 2026-05-22T16:57:45+00:00

I want to put 4 buttons horizontally in a linearlayout. In order to space

  • 0

I want to put 4 buttons horizontally in a linearlayout. In order to space them equally I set android:layout_weight="1" in each button. The problem is that the width of the button is not respected and they fill the whole linearlayout. This works with imageviews, why not with buttons?

Thanks

enter image description here

<LinearLayout android:orientation="horizontal"
    android:layout_width="fill_parent" android:layout_height="50dp" android:background="#FFFFFF">
    <Button android:id="@+id/btn_sort_pert"
        android:layout_width="90dp" android:layout_height="31dp"
        android:layout_gravity="center_vertical" android:gravity="center"
        android:layout_weight="1" android:text="@string/pertinence"
        android:textSize="14sp" android:textColor="#FFFFFF"
        android:background="@drawable/btn_sort" />
    <Button android:id="@+id/btn_sort_dist"
        android:layout_width="90dp" android:layout_height="31dp"
        android:layout_gravity="center_vertical" android:gravity="center"
        android:layout_weight="1" android:text="@string/distance"
        android:textSize="14sp" android:textColor="#FFFFFF"
        android:background="@drawable/btn_sort" />
    <Button android:id="@+id/btn_sort_prix"
        android:layout_width="90dp" android:layout_height="31dp"
        android:layout_gravity="center_vertical" android:gravity="center"
        android:layout_weight="1" android:text="@string/prix"
        android:textSize="14sp" android:textColor="#FFFFFF"
        android:background="@drawable/btn_sort" />
    <Button android:id="@+id/btn_refine"
        android:layout_width="32dp" android:layout_height="31dp"
        android:layout_gravity="center_vertical" android:layout_weight="1" android:background="@drawable/btn_affiner" />
</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-22T16:57:46+00:00Added an answer on May 22, 2026 at 4:57 pm

    EDIT

    You need to add empty views like:

    <LinearLayout android:orientation="horizontal"
        android:layout_width="fill_parent" android:layout_height="50dp" android:background="#FFFFFF">
        <Button android:id="@+id/btn_sort_pert"
            android:layout_width="90dp" android:layout_height="31dp"
            android:layout_gravity="center_vertical" android:gravity="center"
             android:text="@string/pertinence"
            android:textSize="14sp" android:textColor="#FFFFFF"
            android:background="@drawable/btn_sort" />
           <View android:layout_width="0dp" android:layout_height="1dp" 
           android:layout_weight="1">
        <Button android:id="@+id/btn_sort_dist"
            android:layout_width="90dp" android:layout_height="31dp"
            android:layout_gravity="center_vertical" android:gravity="center"
             android:text="@string/distance"
            android:textSize="14sp" android:textColor="#FFFFFF"
            android:background="@drawable/btn_sort" />
         <View android:layout_width="0dp" android:layout_height="1dp" 
          android:layout_weight="1">
        <Button android:id="@+id/btn_sort_prix"
            android:layout_width="90dp" android:layout_height="31dp"
            android:layout_gravity="center_vertical" android:gravity="center"
            android:text="@string/prix"
            android:textSize="14sp" android:textColor="#FFFFFF"
            android:background="@drawable/btn_sort" />
         <View android:layout_width="0dp" android:layout_height="1dp" 
         android:layout_weight="1">
        <Button android:id="@+id/btn_refine"
            android:layout_width="32dp" android:layout_height="31dp"
            android:layout_gravity="center_vertical" android:background="@drawable/btn_affiner" />
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using a LinearLayout to put two buttons horizontally side-by-side, but I want to
I have 3 buttons Docked to left but I want to put them in
I want put a button on android edittextpreference. I create a custom editextpreference: public
i want to put Go button in android appliation softkeyboard for search and other
Problem: I want to put Twitter Share Button in my Google Map InfoWindow. I
I put 4 buttons in a relative layout. I want them to have the
http://buttonspace.com/ I want to put equal space between the 4 buttons at the top,
I want to put buttons in not in the order So what is the
Basically, what I want to do is put some buttons before the tabs in
i have a screen and it is i want the buttons to put under

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.