Android Honeycomb: текст вне центральной кнопки - невозможно центрировать - PullRequest
2 голосов
/ 11 января 2012

У меня проблема с центрированием текста на кнопках в макете, над которым я работаю. Пожалуйста, смотрите скриншот ниже (взятый на вкладке «Графический макет» Eclipse):

Button Text Problem

Я не уверен, что вызвало это. Я пытался поиграть с индивидуальными свойствами макета кнопок, но это не имело никакого эффекта. Ниже приведена моя иерархия макетов:

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>

У кого-нибудь есть идеи, что может быть причиной этого?

Спасибо за вашу помощь!

Ответы [ 2 ]

1 голос
/ 12 января 2012

Я закончил тем, что обновил eclipse, и это решило проблему.Я был крайне разочарован тем, что перезапуск IDE ничего не изменил, тем более что XML не создавал проблем для других.Спасибо всем за помощь!

0 голосов
/ 12 января 2012

Убедитесь, что ширина ваших кнопок внизу установлена ​​на 0dp. Также убедитесь, что их родительский LinearLayout имеет ширину, равную match_parent.

...