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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:50:27+00:00 2026-05-29T13:50:27+00:00

I use tablelayout instead of the custom header title bar Now my layout like

  • 0

I use tablelayout instead of the custom header title bar

Now my layout like the xml I show below, and I want to put the 2 icon and the text align right, but when I use android:layout_gravity="right" it seems not work, so how can I do it ?

This is my layout xml:

  < ? 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" >    
        <TableLayout
            android:id="@+id/tableLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:background="#4494D1" >

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="right" >

                <LinearLayout
                    android:id="@+id/linearLayout3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <TextView

                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:text="简易尺子" 
                        android:textColor="#fff"
                        android:textSize="25dp"
                        android:layout_marginTop="5dp"
                         android:layout_marginLeft="15dp"
                        />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/linearLayout1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" 

                    >

                    <ImageButton
                        android:id="@+id/imageButton1"
                        android:layout_width="28dp"
                        android:layout_height="28dp"
                        android:background="@drawable/android2"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_marginTop="5dp"/>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="关于"
                        android:textColor="#fff" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/linearLayout2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:orientation="vertical" >

                    <ImageButton
                        android:id="@+id/imageButton2"
                        android:layout_width="28dp"
                        android:layout_height="28dp"
                        android:background="@drawable/programs" 
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_marginTop="5dp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="帮助"
                        android:textColor="#fff" />

                </LinearLayout>
            </TableRow>
        </TableLayout>

    <SurfaceView
        android:layout_width="match_parent"
        android:id="@+id/surfaceView1"
        android:layout_height="match_parent">
    </SurfaceView>
</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-29T13:50:29+00:00Added an answer on May 29, 2026 at 1:50 pm

    The layout gravity you set is not to affect the positioning of the TextView and the ImageView in the TableRow, rather it will position them in the wrapping LinearLayout which is not quite what you need. I suggest you define the following attribute to your TableLayout:

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_width="wrap_content"
        android:stretchColumns="0,1">
    

    This will make the first two columns of the raw expand and thus shrink the rightmost column to the right.

    NOTE (IMPORTANT) Currently you do not have a valid layout defined: you have a TableRow in LinearLayout – this is not allowed – you should place the row in TableLayout like the one I have defined.

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

Sidebar

Related Questions

How can I use any layout in .xml files. Let I want to use
For a widget I use a simple layout which contains a TableLayout <?xml version=1.0
Use case: I've just entered insert mode, and typed some text. Now I want
I use TableLayout with android. <?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> <TableLayout
I do not want to use TableLayout because my data model and UI perfectly
I have a custom xml file for my listview and then I use an
Hy! I want to have have a layout like this: The problem is i
I'm learning android development and I'm doing a minesweeper. So I use a tableLayout
I'm trying to use my layout file place rows of TextViews and Buttons. It
I'm using a TableLayout in Android. Right now I have one TableRow with two

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.