2011-10-25 120 views
0

我試圖顯示一系列按鈕的簡單表格,並在它們的右側顯示一個標籤(黑色文本)。模擬器和Eclipse SDK視圖佈局之間的Android差異

首先,在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

的Eclipse SDK視圖和模擬器並不總是相互aggree;),但模擬器通常與設備:)

我不知道爲什麼你的代碼就犯病aggrees,ussually是與填充/邊距有關的事情,但也可能是textapperance大事(不是我自己使用它)。也不要使用margin =「75px」真的不建議使用像px這樣的硬編碼值,而是使用sp代替。請參閱What is the difference between "px", "dp", "dip" and "sp" on Android?以供參考。

+0

謝謝。我想我需要使用「px」。餘量的原因是我有一個9像素的PNG背景圖像,它具有〜75像素的標題。由於標題部分沒有縮放,我(相信我)應該最好指定px中的邊框。 – Brad

+0

但你解決了這個問題嗎? – Warpzit

+0

沒有.......... :( – Brad

相關問題