2014-05-22 38 views
0

我有什麼是一種活動,我的圖像添加到它,我使其作爲背景,用於與下面的XML活性:爲什麼圖像從底部和頂部保持一個空白區域?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".SplashScreen"> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:src="@drawable/splash5" />  
</LinearLayout> 

和圖像尺寸:550像素寬度和800像素的身高

enter image description here

,正如你可以從圖片看,你可以在頂部和底部中看到一個白色的空間..爲什麼這種情況發生,即使它是填補母公司寬度和高度?

+3

機器人:ScaleType = 「fitXy」 爲ImageView的 –

+0

或使用機器人:背景代替機器人的:SRC。它會延伸填充。其他2個注意事項:fill_parent從API級別8開始已棄用 - 使用match_parent。和centerHorizo​​ntal或CenterVertical僅在RelativaLayouts中使用,如果您使用wrap_content,not_ match_parent –

回答

1

使用這樣的:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".SplashScreen"> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:src="@drawable/splash5" 
     android:scaleType="fitXY" 

     />  
</LinearLayout> 
相關問題