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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:15:20+00:00 2026-05-29T09:15:20+00:00

here you are my problem: I want to do a layout that look like

  • 0

here you are my problem: I want to do a layout that look like this grid in android:

enter image description here

In order to do so, I have created this layout:

     <?xml version="1.0" encoding="utf-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/RelativeLayout1"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:gravity="center"
     android:orientation="vertical" >


    <TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_weight="0.3">

        <Button
            android:id="@+id/clientimain"
            android:layout_width="0dip"
            android:layout_weight="1" android:layout_height="fill_parent"/>



        <Button
            android:id="@+id/button1"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Button" />

     </TableRow>

     <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.3" >

        <Button
            android:id="@+id/button2"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Button"/>

        <Button
            android:id="@+id/button6"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Button" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.3" >

        <Button
            android:id="@+id/button3"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Button"
             />

        <Button
            android:id="@+id/button7"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Button"
             />

    </TableRow>

   </TableLayout>

   </RelativeLayout>

So basically it is composed by 6 buttons in a table layout with the weight property setted correctly(or I hope so!). The result looks good until I’ll try to set the background property of each button. In that case the button takes the height of the image that a put in (the width is ok). For instance if I set the background image which size is 96px x 96px the result look like this:

enter image description here

Is there a way to prevent this button “stretch” and to correctly center the image?
I’ve tried to change the height property for each table row, to change the button max height property and also to change the button type with an imagebutton (and set the src property with the wanted icon) but i did not accomplished the wanted result.
I’ve also red the google documentation about supporting multiple screens and about each basic layout but I did not find any solution.
Thanks in advance to anyone that would like to help me!

Andrea

  • 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-29T09:15:21+00:00Added an answer on May 29, 2026 at 9:15 am

    Set the layout height of the table row as 0dip and set the weight as 1

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

    This should fix your problem


    Change

    <Button
                android:id="@+id/clientimain"
                android:layout_width="0dip"
                android:layout_weight="1" android:layout_height="fill_parent"/>
    

    to

    <Button
                android:id="@+id/clientimain"
                android:layout_width="0dip"
                android:layout_weight="1" android:layout_height="fill_parent"/>
    

    this could work, worth a try, in eclipse for me it renders right how you had it first, maybe you could try cleaning your project (Project > clean project) because it should be right as it is


    You code should be like this:

    <?xml version="1.0" encoding="utf-8"?>
         <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/RelativeLayout1"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:gravity="center"
         android:orientation="vertical" >
    
    
        <TableLayout
            android:id="@+id/tableLayout1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
    
            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1" >
    
                <Button
                    android:id="@+id/clientimain"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="1" />
    
                <Button
                    android:id="@+id/button1"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:text="Button" />
            </TableRow>
    
            <TableRow
                android:id="@+id/tableRow2"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1" >
    
                <Button
                    android:id="@+id/button2"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:text="Button" />
    
                <Button
                    android:id="@+id/button6"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:text="Button" />
            </TableRow>
    
            <TableRow
                android:id="@+id/tableRow3"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1" >
    
                <Button
                    android:id="@+id/button3"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:text="Button" />
    
                <Button
                    android:id="@+id/button7"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:text="Button" />
            </TableRow>
        </TableLayout>
    
       </RelativeLayout>
    

    <?xml version="1.0" encoding="utf-8"?>
         <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/RelativeLayout1"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:gravity="center"
         android:orientation="vertical" >
    
    
        <TableLayout
            android:id="@+id/tableLayout1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
    
    
            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1" >
    
                <ImageButton
                    android:id="@+id/imageButton1"
                    android:layout_width="0dp"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:src="@drawable/ic_launcher" />
    
                <ImageButton
                    android:id="@+id/imageButton2"
                    android:layout_width="0dp"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:src="@drawable/ic_launcher" />
            </TableRow>
    
    
            <TableRow
                android:id="@+id/tableRow2"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1" >
    
                <ImageButton
                    android:id="@+id/imageButton3"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:src="@drawable/ic_launcher" />
    
                <ImageButton
                    android:id="@+id/imageButton4"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:src="@drawable/ic_launcher" />
            </TableRow>
    
    
            <TableRow
                android:id="@+id/tableRow3"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1" >
    
                <ImageButton
                    android:id="@+id/imageButton5"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:src="@drawable/ic_launcher" />
    
                <ImageButton
                    android:id="@+id/imageButton6"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:src="@drawable/ic_launcher" />
            </TableRow>
    
        </TableLayout>
    
       </RelativeLayout>
    

    still not changing anything, how big is the size of the image?

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

Sidebar

Related Questions

I have the following layout for my ImageView : <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
here is my Problem, I want to pass the integer 1 when this canvas
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
Here is the layout I want: Grid with 2 columns, 2 rows Row 1
I have a ListView in Android that I want to split in pages that
Think that I have many activities,and all I want is this: I have a
Look at the XML code here please: <TableLayout android:id=@+id/tableLayout1 android:layout_width=fill_parent android:layout_height=fill_parent android:padding=10dip xmlns:android=http://schemas.android.com/apk/res/android> <TableRow
I have another CSS problem. A layout that escapes me. I could, I suppose,
Noob Question here. I have created and successfully added an additional Page Layout to
I have a problem here and I cant get it to work... I want

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.