2012-02-23 146 views
0

我使用兩個圖像構建佈局xml,並將LinearLayout作爲背景添加圖像。 問題是,我的頂部圖像在主屏幕下開始10 px,然後我看到了LinearLayout背景圖像的頂部。佈局Xml和圖像

<?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/hazmanag" android:layout_gravity="top"> 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/uph" 
     android:layout_gravity="top|center"/> 

     <ImageView 
      android:id="@+id/imageView2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/coupon" android:layout_gravity="top|center"/> 

    </LinearLayout> 
+0

當你說它在主屏幕下面開始10px時,你是在談論標題欄嗎? – 2012-02-23 19:00:32

+0

我有tha主屏幕,在狀態欄下顯示背景圖像,只有在狀態欄的10-20像素後顯示第一個圖像 – MTA 2012-02-23 19:05:34

+0

我會嘗試專門設置邊距。 – 2012-02-23 20:50:19

回答

0

你應該嘗試這樣的事:

<ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop = "50dp" 
     android:src="@drawable/uph" 
    android:layout_gravity="top|center"/> 

您已經定義的Android利潤率在所有方向上,下,左,右,所以你可以在任何地方放置物體在屏幕!