2011-08-17 59 views
0

我已經使用這個計算:如何在3中均勻分割屏幕?

size = act.getWindow().getDecorView().getWidth()/3; 

int dip = (int)TypedValue.applyDimension(
       TypedValue.COMPLEX_UNIT_DIP, 
       size, 
       r.getDisplayMetrics() 
     ); 

然而,我的圖片是太大了。我需要做什麼?

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 

     <ImageView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:src="@drawable/example" 
        weight="1" /> 

     <ImageView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:src="@drawable/example" 
        weight="1" /> 

     <ImageView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:src="@drawable/example" 
        weight="1" /> 

  </LinearLayout> 

您還可以使用scaleType屬性來改變圖像如何縮放,希望這有助於:定義XML時

+0

'LinearLayout'和'weight'屬性不是一個選項嗎? – dmon

回答

5

一個簡單的方法是將佈局體重!