2015-11-08 110 views
0

因此,我有一個屏幕分爲2.在屏幕的上半部分,我有一個圖像,在其下半部分,我有一個文本。無論如何,我都無法正確地填充屏幕。它始終以圖像頂部或側面的空白區域結束(如下圖所示):Blank sides,Blank top。如果有人能幫我解決這個問題,我會很感激。如何將圖像設置爲strecth並填充屏幕? (屏幕被劃入2)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:id="@+id/flag" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     /> 

    <TextView 
     android:id="@+id/population" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:gravity="center" 
     /> 

</LinearLayout> 
+0

我試圖使用它對齊和重力沒有成功。我沒有使用scaleType。 –

+0

你可以發佈你的佈局的代碼? – LordRaydenMK

+0

我編輯了帖子併發布了佈局的代碼,先生。 –

回答

0
<ImageView 
     android:id="@+id/flag" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="centerCrop" 
     android:layout_weight="1"/> 

應該工作。你可以找到其他可能的值scaleTypehere.

+0

非常感謝,先生。它適用於android:scaleType =「centerCrop」和android:scaleType =「fitXY」。我完全忘了這個。 –

+0

@StelianTeodor歡迎您。您可以將問題標記爲已回答。問候 – LordRaydenMK