Center a TextView in a TableRow in a TableLayout

Marco Lau

I am trying to build something like a header. I tried using android:gravity="center" and android:textAlignment="center" on the TextView but it doesn't center the text. I don't know where the problem is.

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#008000" >

    <TextView
        android:id="@+id/HeaderTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        <!--android:textAlignment="center"
        android:gravity="center"-->
        android:text="@string/header"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#FFF"
        android:textStyle="italic" />

</TableRow>

</TableLayout>
shivang Trivedi
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:background="#008000" >

    <TextView
        android:id="@+id/HeaderTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="header"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#FFF"
        android:textStyle="italic" />
</TableRow>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Center a TextView in a TableRow in a TableLayout

From Dev

Can't center textview in tablelayout

From Dev

TextView inside TableLayout and TableRow doesn't wrap text

From Dev

Inserting TableRows into TableLayout programmatically - TextView inside TableRow won't display

From Dev

how to set weight of textview Dyanamicaly inside Tablerow in TableLayout?

From Dev

how to put dynamic TableRow in TableLayout and place Textview dynamically in TableRow using Android?

From Dev

set the Columns of a TableRow in a TableLayout

From Dev

set the Columns of a TableRow in a TableLayout

From Dev

TextView alignment in the TableRow

From Dev

How to update tablerow textview?

From Dev

How to center a TableRow programmatically

From Dev

Cannot Center Button in tablerow

From Dev

iOS/Swift programmatic equivalent of Android TableLayout/TableRow

From Dev

TableLayout, Different Button actions depending on data in TableRow

From Dev

Add TableRow xml layout to TableLayout on button click

From Dev

Float left TextView and TableLayout

From Dev

Expand width of TextView, TableRow, and TableView

From Dev

Tablerow textview above edittext (Android)

From Dev

Android TextView align inside of TableLayout

From Dev

How to add a image at the center of a TableLayout

From Dev

Why does nothing appear when adding TableRow to TableLayout from code

From Dev

How to add a TableRow to TableLayout without making changes to other Rows

From Dev

how to display textview to right side in tablerow in android

From Dev

Wrap text in syllables TextView located in TableRow

From Dev

TextView not always expanding to a second line in TableLayout

From Dev

Set the same height to a TextView and an EditText in a row of a TableLayout?

From Dev

TextView not always expanding to a second line in TableLayout

From Dev

Android textview center positioning

From Dev

Center a button and textView

Related Related

  1. 1

    Center a TextView in a TableRow in a TableLayout

  2. 2

    Can't center textview in tablelayout

  3. 3

    TextView inside TableLayout and TableRow doesn't wrap text

  4. 4

    Inserting TableRows into TableLayout programmatically - TextView inside TableRow won't display

  5. 5

    how to set weight of textview Dyanamicaly inside Tablerow in TableLayout?

  6. 6

    how to put dynamic TableRow in TableLayout and place Textview dynamically in TableRow using Android?

  7. 7

    set the Columns of a TableRow in a TableLayout

  8. 8

    set the Columns of a TableRow in a TableLayout

  9. 9

    TextView alignment in the TableRow

  10. 10

    How to update tablerow textview?

  11. 11

    How to center a TableRow programmatically

  12. 12

    Cannot Center Button in tablerow

  13. 13

    iOS/Swift programmatic equivalent of Android TableLayout/TableRow

  14. 14

    TableLayout, Different Button actions depending on data in TableRow

  15. 15

    Add TableRow xml layout to TableLayout on button click

  16. 16

    Float left TextView and TableLayout

  17. 17

    Expand width of TextView, TableRow, and TableView

  18. 18

    Tablerow textview above edittext (Android)

  19. 19

    Android TextView align inside of TableLayout

  20. 20

    How to add a image at the center of a TableLayout

  21. 21

    Why does nothing appear when adding TableRow to TableLayout from code

  22. 22

    How to add a TableRow to TableLayout without making changes to other Rows

  23. 23

    how to display textview to right side in tablerow in android

  24. 24

    Wrap text in syllables TextView located in TableRow

  25. 25

    TextView not always expanding to a second line in TableLayout

  26. 26

    Set the same height to a TextView and an EditText in a row of a TableLayout?

  27. 27

    TextView not always expanding to a second line in TableLayout

  28. 28

    Android textview center positioning

  29. 29

    Center a button and textView

HotTag

Archive