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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:18:37+00:00 2026-06-14T20:18:37+00:00

I have an XML grid table layout menu of equally sized buttons the buttons

  • 0

I have an XML grid table layout menu of equally sized buttons the buttons change their size depending on the phone resolution. The idea is to make the menu fill the screen with equally sized buttons. This works perfect when the buttons don’t have a text label. But as soon as i add text on the button then the width of the button is also affected by the text. If i change the text size to a smaller size, then the button automatically re-sizes to be smaller than the others. For example: Name for Button A is “Home” Name for Button B is “Notifications”
My problem is that Button B becomes bigger than Button A, i want all button to have the same width no mater what the label text size is.
I will also attach the XML layout.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="4dp"
    android:background="#2b2c31"
    android:orientation="vertical"  >

    <include
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        layout="@layout/layout_topheader" />


        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="10dp"
            android:stretchColumns="*" >

                <TableRow 
            android:layout_weight="1"
            android:gravity="center"
            android:padding="10dp" >

                    <Button
                        android:id="@+id/buttonScan"
                        android:layout_width="fill_parent" 
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@drawable/btn"
                        android:text="Refill"                            
                        android:layout_margin="10dp"
                        android:textColor="@color/status_text"
                        android:textSize="30dip"
                        android:textStyle="bold" />

                    <Button
                        android:id="@+id/buttonSetReminder"
                       android:layout_width="fill_parent"                              
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@drawable/btn"
                        android:text="Reminders"                         
                        android:layout_margin="10dp"
                        android:textColor="@color/status_text"
                        android:textSize="30dip"
                        android:textStyle="bold" />

                 </TableRow>

                 <TableRow 
            android:layout_weight="1"
            android:gravity="center"
            android:padding="10dp" >

                    <Button
                        android:id="@+id/buttonRewards"
                        android:layout_width="fill_parent"                             
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@drawable/btn" 

                        android:layout_margin="10dp"
                        android:textSize="30dip"
                        android:textColorHint="@color/status_text" 
                        android:textColor="@color/status_text"
                        android:text="Rewards"
                        android:textStyle="bold" />

                    <Button
                        android:id="@+id/buttonTracker"
                        android:layout_width="fill_parent"                            
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@drawable/btn"
                        android:text=" Tracker"

                        android:layout_margin="10dp"
                        android:textColor="@color/status_text"
                        android:textSize="30dip"
                        android:textStyle="bold" />

                 </TableRow>

                 <TableRow 
                    android:layout_weight="1"
                    android:gravity="center"
                    android:padding="10dp" >

                    <Button
                        android:id="@+id/buttonProfile"
                        android:layout_width="fill_parent"                             
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@drawable/btn"
                        android:text="Profile"                           
                        android:layout_margin="10dp"
                        android:textColor="@color/status_text"
                        android:textSize="30dip"
                        android:textStyle="bold" />

                    <Button
                        android:id="@+id/buttonChat"
                        android:layout_width="fill_parent"                             
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="@drawable/chaticon"
                        android:text="Chat"                           
                        android:layout_margin="10dp"
                        android:textColor="@color/status_text"
                        android:textSize="30dip"
                        android:textStyle="bold" />

                 </TableRow>

                  <LinearLayout
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:background="#ffffff"
             android:orientation="vertical" >


                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:src="@drawable/add3" />

      </LinearLayout>                    

   </TableLayout>        

</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-06-14T20:18:38+00:00Added an answer on June 14, 2026 at 8:18 pm

    Not sure if it is the best way to do it but, I had a similar problem and solved it by getting the screen dimensions at run time with:

        DisplayMetrics displaymetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    

    Then setting the button width as:
    int buttonWidth = displaymetrics.widthPixels/2;

    And finally setting the max and min widths/heights as buttonWidth

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

Sidebar

Related Questions

I need to have a grid (created by program, not by xml) of equally
I have the following code for my grid (I use an XML file in
In my Android app, I have a GridView layout with a set of Buttons.
I have a table DEFINITIONS where I store my xml definitions form my components
I have created a data table using disconnected class, also created the data set,xml
I am writing a windows phone 7 app and i have an xml file
I have xml file with such structure: ... <outer> ... <inner/> ... </outer> ...
I have XML in the following form that I want to parse with PHP
I have xml as follows <Search> <Term /> <And /> <Term /> <And />
I Have XML similar to this(omitted parts for brevity): <uformrecord> <state>Submitted</state> <created>2012-06-19T11:31:54</created> <updated>2012-06-19T11:32:13</updated> <id>53225sas3c1-d727-42cd-93a6-97cd778e5ee9</id>

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.