Center a button and textView

Hoo

Can someone help me to figure out my problem? At the last row of my table, I have a button and I want it to be centered. Below is the coding snippet.

<TableRow>
    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_gravity="center"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent">

        <Button
            android:id="@+id/button1"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Button"/>
    </LinearLayout>
</TableRow>
  1. Why doesn't the coding work?
  2. How to put a textView beside the button?

Thanks..

rajan.kali
<TableRow
 android:gravity="center_horizontal"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"> 

 <LinearLayout android:id="@+id/linearLayout2"   
 android:layout_height="fill_parent" 
 android:layout_gravity="center" 
 android:layout_width="wrap_content">

    <Button android:text="Button" android:id="@+id/button1"   
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content">
    </Button>

   <TextView 
    ...
    android:layout_width="wrap_content" 
    ...
    />

 </LinearLayout>

</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

How to Get location of a button and make Textview appear in the Center of button with Onclick

From Dev

How to Get location of a button and make Textview appear in the Center of button with Onclick

From Dev

How to set textview in center of G+ sign in button in Android

From Dev

Android textview center positioning

From Dev

Android textview center letter

From Dev

TextView will not center its content

From Dev

Android - Center Textview in LinearLayout

From Dev

Center a TextView in a TableRow in a TableLayout

From Dev

Align TextView to center of RelativeLayout

From Dev

Center a TextView in a TableRow in a TableLayout

From Dev

TextView will not center its content

From Dev

Unable to center the text in textview

From Dev

Dynamically create textview in center

From Dev

TextView Center Gravity not working

From Dev

Image left to TextView, Textview should be in center

From Dev

Can't center textview in tablelayout

From Dev

Android: Vertically Center TextView in LinearLayout

From Dev

textview not align center below of imageview

From Dev

Align a textview to the center of progressbar in Android

From Dev

a textView refuses to center as a son of LinearLayout

From Dev

Layout: TextView at the top and ListView at the center

From Dev

Center ImageView and TextView Side by side

From Dev

Center align TextView in android layout

From Dev

android gravity center not working in textview

From Dev

Textview in center below of imageview Android

From Dev

Set Textview + Edittext + Button

From Dev

use textView as a button

From Dev

Pointing to a looped textview and Button

From Dev

Adding the textview on button click

Related Related

HotTag

Archive