2011-09-21 53 views
0

我正在創建一個App Widget,而且我遇到了一個奇怪的問題。在Eclipse圖形佈局編輯器,我的小部件的佈局是這樣的:Android AppWidget,海量佈局差異

How widget appears in Eclipse layout manager

然而,當我在模擬器上安裝它/我的手機,它看起來像這樣:

How widget appears on device emulator

這裏是有問題的佈局代碼:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:layout_gravity="center_horizontal" android:gravity="center_horizontal"> 
    <RelativeLayout android:background="@drawable/blackbg" 
     android:layout_width="290dp" android:layout_height="145dp"> 
     <ImageView android:layout_width="wrap_content" android:src="@drawable/clock_colon" 
      android:layout_height="107dp" android:layout_marginRight="10dp" 
      android:layout_marginLeft="10dp" android:layout_marginTop="5dp" 
      android:layout_centerInParent="true" android:id="@+id/colon" /> 
     <ImageView android:layout_width="wrap_content" android:src="@drawable/num_0" 
      android:layout_height="107dp" android:layout_marginRight="5dp" 
      android:layout_marginLeft="5dp" android:id="@+id/hour2" 
      android:layout_toLeftOf="@id/colon" android:layout_centerVertical="true" /> 
     <ImageView android:layout_width="wrap_content" android:src="@drawable/num_1" 
      android:layout_height="107dp" android:layout_marginRight="5dp" 
      android:layout_marginLeft="5dp" android:id="@+id/hour1" 
      android:layout_marginTop="5dp" android:layout_toLeftOf="@id/hour2" 
      android:layout_centerVertical="true" /> 
     <ImageView android:layout_width="wrap_content" android:src="@drawable/num_3" 
      android:layout_height="107dp" android:layout_marginRight="5dp" 
      android:layout_marginLeft="5dp" android:id="@+id/minute1" 
      android:layout_marginTop="5dp" android:layout_toRightOf="@id/colon" 
      android:layout_centerVertical="true" /> 
     <ImageView android:layout_width="wrap_content" android:src="@drawable/num_2" 
      android:layout_height="107dp" android:layout_marginRight="5dp" 
      android:layout_marginLeft="5dp" android:id="@+id/minute2" 
      android:layout_marginTop="5dp" android:layout_toRightOf="@id/minute1" 
      android:layout_centerVertical="true" /> 
     <ImageView android:layout_width="wrap_content" android:src="@drawable/clock_pm" 
      android:layout_height="wrap_content" android:id="@+id/clock_ampm" 
      android:layout_below="@id/minute2" android:layout_alignParentRight="true" 
      android:layout_marginRight="15dp" android:layout_marginBottom="5dp" /> 
    </RelativeLayout> 
</LinearLayout> 

那麼你怎麼看?這些數字是如何被切斷和隔開這樣奇怪的。謝謝!

回答

1

手動設置你的RelativeLayoutheight和你ImageViews107dpheight和您的圖片可能無法正常滿足您的ImageView內。所以,你應該考慮以下幾點:

+0

更新代碼然後 –

0

問題最終導致我已經爲容器RelativeLayout設置了大小。顯然你不能那樣做。

+0

是我告訴你的......你是什麼意思,你不能這樣做? –

+0

哦,嘿,你告訴我要這麼做。我的道歉,回答接受!我不知道我的大腦有時會走向何方 – Nick