2014-06-16 16 views
0

我試圖在屏幕頂部放置圖像視圖,但它在其上方和下方都有一些類型的邊距。所以我嘗試了adjustViewBounds = true,它工作,但它不會達到屏幕的兩側。我只是希望它與屏幕頂部齊平,併到達兩側。有什麼建議麼?無法讓imageview與屏幕頂部齊平

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="match_parent" 
tools:context="${packageName}.${activityClass}" 
android:orientation="vertical" > 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/title_bar"/> 

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="200dp" > 

    <LinearLayout 
     android:id="@+id/goals" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="center" 
     android:orientation="vertical" > 
    </LinearLayout> 
</ScrollView> 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/black" > 
</RelativeLayout> 

+0

發佈您的佈局XML。 – Karakuri

+0

我發佈了xml – user3741413

回答

0

如果只是顏色的標題欄 - 那麼它是有意義的使用只是查看例如並設置背景屬性所需的顏色。如果您有自定義圖像,並且無法使用默認的ImageView屬性進行調整 - 那麼您可以從圖像製作9Patch,並將其作爲背景(在9patch中,您自己決定如何劃分圖像以及放置內容的位置)。你可以在android SDK中找到9patch工具。有關9patch的更多信息: http://developer.android.com/reference/android/graphics/NinePatch.html

0

我也有同樣的問題。我終於實現了使用上的ImageView的像這樣的頂級負利潤率爲:

android:layout_marginTop="-4dp" 

您可能要玩找DP的最佳數量爲您服務。希望這可以幫助。