Android Расхождения между эмулятором и компоновкой Eclipse SDK - PullRequest
0 голосов
/ 25 октября 2011

Я пытаюсь отобразить простую таблицу с рядом кнопок и надписями справа от них (черный текст).

Сначала все выглядит правильно в графическом макете SDK. Теперь (без внесения каких-либо изменений) в SDK все выглядит правильно, за исключением того факта, что текст не черный, как таковой:

Eclipse Graphical Layout View

Когда я запускаю его в эмуляторе, все выглядит примерно по центру, и текст имеет правильный цвет, но отображается только самая левая сторона текста.

Running in the Emulator

Что здесь происходит?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/map_description_background">
    <TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tableLayout1" android:layout_gravity="fill_horizontal">
        <TableRow android:id="@+id/tableRow1" android:layout_height="wrap_content" android:layout_marginTop="75px" android:layout_width="wrap_content">
            <ToggleButton android:textOff="Nautical" android:textOn="Statued" android:id="@+id/unitsButton" android:layout_width="wrap_content" android:layout_height="wrap_content"></ToggleButton>
            <TextView android:textAppearance="?android:attr/textAppearanceLarge" android:text="Units" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/textView1" android:textColor="@color/maincolors"></TextView>
        </TableRow>
        <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content">
            <ToggleButton android:textOff="GPS" android:textOn="Magnetic" android:id="@+id/toggleButton2" android:layout_width="wrap_content" android:layout_height="wrap_content"></ToggleButton>
            <TextView android:textAppearance="?android:attr/textAppearanceLarge" android:text="Heading" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/textView3" android:textColor="@color/maincolors"></TextView>
        </TableRow>
        <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content">
            <Button android:text="Help" android:onClick="clickHelpButton" android:id="@+id/helpButton" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
        </TableRow>
        <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow>
    </TableLayout>
    <Button android:text="Done" android:id="@+id/done" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="clickDoneButton"></Button>

</LinearLayout>

1 Ответ

1 голос
/ 25 октября 2011

Eclipse SDK view и эмулятор не всегда согласуются друг с другом;) но эмулятор обычно согласуется с устройствами:)

Я не уверен, почему ваш код работает, обычно это что-тосделать с padding / margin, но это также может быть большой вещью (не использовал ее сам).Также не используйте margin = "75px", на самом деле не рекомендуется использовать жестко закодированные значения, такие как px, вместо этого используйте sp.См. В чем разница между «px», «dp», «dip» и «sp» на Android? для справки.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...