2011-07-06 40 views
1

出於某種原因,我無法將ImageView對齊到我的Android應用程序中的頂部活動。例如:Android無法將ImageView對齊到活動頂部

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:scaleType="fitStart" 
     android:src="@drawable/myImage" /> 

    <ListView android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 

我能得到的ImageView對齊與「fitStart」活動的頂部,但是不那麼ImageView的不會是頂部的所有道路。既然ImageView在最前面,那麼ListView並不直接在它下面。相反,它是屏幕的四分之一。這發生在我所有的活動上,即使沒有ListView的活動。

作爲一個附註,我從AndroidManifest中刪除了系統標題欄。但是,即使我將它們添加回來,問題仍然存在。

任何想法?

回答

1

通過使用RelativeLayout的

-1

也許這是因爲您的圖片具有透明邊框?這裏是我的意思是:

enter image description here

+0

固定不幸的是,情況並非如此,我相信沒有透明邊框。不錯的想法,但! – littleK

+0

你可以把你的圖片上傳到你的問題中嗎?我想在我的佈局中使用它... – inazaruk

+0

好吧,我在您的佈局中使用了純色圖像,在我的情況下,圖像完全與頂部對齊。 – inazaruk

0

喜的問題是烏拉圭回合使用android:layout_gravity="center_horizontal"爲此將調整視圖父佈局的中心的ImageView的...

也有看this

希望這能解決你的問題......

+0

嗯,即使當我刪除「android:layout_gravity =」center_horizo​​ntal「我仍然面臨的問題,ImageView和ListView不會對齊的活動的頂部... – littleK

+0

你可以發佈視圖的屏幕截圖你越來越.. – Dinash

-1

看來,我用的是圖片太大,而且縮放後的問題出現。一旦我使用了一個較小的圖像,一切都完美對齊。謝謝!