Подтвердить что ты не робот

Текст кнопки Android не центрирован при использовании API 17 для рендеринга

В графическом представлении макета, когда я выбираю API 15 или ниже от кнопки, показанной на изображении ниже, текст в окруженных кнопках выглядит нормально.

enter image description here

Когда я выбираю API 17, текст перемещается, хотя код xml тот же. Изменение прокладки кнопок не помогает.

enter image description here

Это просто проблема с Eclipse или возможно, что новые версии андроида могут видеть этот смещенный текст?

Какое обходное решение исправить это?

Код XML:

<RelativeLayout 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=".HomeActivity" >

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_margin="3dp" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:src="@drawable/label" />
</LinearLayout>

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/linearLayout1"
    android:layout_below="@+id/linearLayout1"
    android:layout_marginTop="20dp"
    android:text="@string/about_title"
    android:textSize="20sp" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_alignRight="@+id/linearLayout1"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="5dp"
    android:text="@string/temp" />

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView2"
    android:layout_alignRight="@+id/textView2"
    android:layout_below="@+id/textView2"
    android:layout_marginTop="20dp"
    android:baselineAligned="false" >

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

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

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

4b9b3361

Ответ 1

android:gravity="center" не помог

Я дважды перезапустил eclipse. Как ни странно, это не помогло при первом перезапуске, но после второго показалось хорошо. Кроме того, он отлично работает на устройстве. Извиняясь за этот вопрос, я, должно быть, дождался, прежде чем публиковать вопрос.

Ответ 2

Не уверен, что стиль по умолчанию для кнопок изменился в API17... возможно...

В любом случае добавление android:gravity="center" должно быть исправлено для вас.

Ответ 3

Я не знаю, я столкнулся с этой проблемой, проверьте перезапуск затмения.. и проверьте..

Ответ 4

добавление android:gravity="center" должно быть исправлено для вас