2012-03-28 72 views
0

不改變我這裏有一個XML代碼:佈局權重XML

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

    > 
    <fragment 
     android:name="com.powergroup.split.view.powerListFragment" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@+id/powerlist_fragment" 
     android:layout_weight="45" 

     > 
    </fragment> 
    <fragment 
     android:name="com.powergroup.split.view.powerViewerFragment" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@+id/powerview_fragment" 
     android:layout_weight="55" 
     > 
    </fragment> 
</LinearLayout> 

,但如果我改變layout_weight的價值它沒有采取任何作用,始終顯示相同的,我怎麼能弄清楚?

回答

0

您需要設置片段'layout_width0dp爲了加權踢入。見下:

android:layout_width="0dp" 
+0

我做了,但沒有發生變化 – 2012-03-28 09:30:39

+0

您是否將它設置爲兩個碎片? – waqaslam 2012-03-28 09:56:53

0

* layout_weight *只適用於「未使用」的像素分佈。所有的片段都具有fill_parent作爲寬度。所以在這種情況下沒有「未使用」的像素。嘗試設置layout_width =「0dip」。