Search code examples
androideclipseandroid-layoutandroid-3.0-honeycomb

Android Honeycomb: Off-center button text - unable to center


I have a problem with centering text on buttons in a layout that I am working on. Please see the screenshot below (taken within eclipse's "Graphical Layout" tab):

Button Text Problem

I'm not sure what's causing this. I tried playing around with the individual layout properties of the buttons, but this has not had any effect. The following is my layout hierarchy:

LinearLayout (orientation is "vertical")
    ...
    RelativeLayout
        Button ("MM/DD/YYYY")
        Button ("HH:MM")
        TextView ("to")
        Button ("MM/DD/YYYY")
        Button ("HH:MM")
    ...
    LinearLayout (orientation is "horizontal")
        Button ("Close"; layout_weight is "1")
        Button ("Reserve Room"; layout_weight is "1")

XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="1024dp"
    android:layout_height="640dp"
    android:orientation="vertical"
    android:padding="10dp" >
    ...
    <RelativeLayout
        android:id="@+id/dateTimePickersLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/startingDateButton"
            android:layout_width="244dp"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:text="@string/mm_dd_yyyy" />

        <Button
            android:id="@+id/endingTimeButton"
            android:layout_width="244dp"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:text="@string/hh_mm" />

        <Button
            android:id="@+id/endingDateButton"
            android:layout_width="244dp"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/endingTimeButton"
            android:text="@string/mm_dd_yyyy" />

        <Button
            android:id="@+id/startingTimeButton"
            android:layout_width="244dp"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toRightOf="@+id/startingDateButton"
            android:text="@string/hh_mm" />

        <TextView
            android:id="@+id/toTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerInParent="true"
            android:text="@string/to"
            android:textSize="18dp" />
    </RelativeLayout>
    ...
    <LinearLayout
        android:id="@+id/LinearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/closeButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/close" />

        <Button
            android:id="@+id/reserveRoomButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/reserve_room" />
    </LinearLayout>
</LinearLayout>

Anyone have any ideas what may be causing this?

Thank you for your help!


Solution

  • I ended up updating eclipse and that fixed the problem. I was extremely disappointed that restarting the IDE did not change anything, especially since the XML had not posed any problems for others. Thanks for the help, everyone!