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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:15:22+00:00 2026-05-27T17:15:22+00:00

Can anyone tell me how to make my sample below <?xml version=1.0 encoding=utf-8?> <LinearLayout

  • 0

Can anyone tell me how to make my sample below

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:gravity="center"
        android:layout_height="wrap_content" >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#300000"
        android:textColor="#ff0000"
        android:text="Sample Layout"/>
    </LinearLayout>
    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    <TableRow>
    <Button
        android:layout_column="1"
        android:layout_height="wrap_content"
        android:background="@drawable/icon"
        android:padding="2dip"/>
    <Button
        android:layout_column="2"
        android:layout_height="wrap_content"
        android:background="@drawable/icon"
        android:padding="2dip"/>
    <Button
        android:layout_column="3"
        android:layout_height="wrap_content"
        android:background="@drawable/icon"
        android:padding="2dip"/>
    </TableRow>
    <TableRow>
    <TextView
        android:layout_column="1"
        android:layout_height="wrap_content"
        android:padding="2dip"
        android:text="News Feed"/>
    <TextView
        android:layout_column="2"
        android:layout_height="wrap_content"
        android:text="Profile"
        android:padding="2dip"/>
    <TextView
        android:layout_column="3"
        android:layout_height="wrap_content"
        android:text="Friends"
        android:padding="2dip"/>
    </TableRow>
    <TableRow>
    <Button
        android:layout_column="1"
        android:layout_height="wrap_content"
        android:background="@drawable/icon"
        android:padding="2dip"/>
    <Button
        android:layout_column="2"
        android:layout_height="wrap_content"
        android:background="@drawable/icon"
        android:padding="2dip"/>
    <Button
        android:layout_column="3"
        android:layout_height="wrap_content"
        android:background="@drawable/icon"
        android:padding="2dip"/>
    </TableRow>
    <TableRow>
    <TextView
        android:layout_column="1"
        android:layout_height="wrap_content"
        android:text="Messages"
        android:padding="5dip"/>
    <TextView
        android:layout_column="2"
        android:layout_height="wrap_content"
        android:text="Places"
        android:padding="5dip"/>
    <TextView
        android:layout_column="3"
        android:layout_height="wrap_content"
        android:text="Groups"
        android:padding="5dip"/>
    </TableRow>
    </TableLayout>
</LinearLayout>

My layout

look more like the target example below. The padding doesn’t seem to be working as expected and I also think it’s needed to center the full table layout. Can someone help me to understand what’s going wrong? And what I need to modify to match the target layout (3×2 instead of 3×3)? Thanks.

Target Layout

  • 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-27T17:15:22+00:00Added an answer on May 27, 2026 at 5:15 pm

    Use ImageButton instead of Button, and use a nested LinearLayout in each table cell to center the text correctly under each button :

    <TableRow>
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
            <ImageButton
                android:layout_gravity="center_horizontal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#00000000"
                android:src="@drawable/icon" />
            <TextView
                android:layout_gravity="center_horizontal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="2dip"
                android:text="News Feed"/>
        </LinearLayout>
    
        <LinearLayout>
            ...
        </LinearLayout>
    </TableRow>
    

    Notice android:layout_gravity="center_horizontal" which centers your view horizontally in the parent view. This code may need some improvements, but it is the general idea you should follow (use layout_gravity, nested layouts, and ImageButtons).

    You can also improve your table layout so it will use the whole space available :

    <TableLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:stretchColumns="*" >
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me how to make a flexible AppWidgets in Android according to
Can anyone tell me how can we make our browser as default in Android?
Can anyone tell me how to make a div's background transparent, but with a
Can anyone please tell me how do I make this script run in IE
Can anyone please tell me if Certifying Authorities (CAs) are allowed to make modifications
I want to make a drop-down list from scratch. Can anyone please tell me
Can anyone tell me what version of the .NET framework (CLR and BCL) is
Can anyone tell me if its possible to make a glow filter effect around
Can anyone tell me why this crashes my program? It's suppose to make it
Can anyone tell why visiting the below link might lead IE7 to say they

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.