2011-06-22 24 views
0

我有了這個代碼,我的工作:單獨的佈局同樣

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:weightSum="3" 
android:id="@+id/main" 
> 
<RelativeLayout 
    android:layout_width="330dp" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    android:id="@+id/linear1" 
> 
    <TextView 
     android:text="List1" 
     android:textSize="40px" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/shows_text" 
    /> 
    <ListView 
     android:layout_height="wrap_content" 
     android:id="@+id/listView1" 
     android:layout_width="fill_parent" 
     android:layout_below="@id/shows_text" 
    /> 
</RelativeLayout> 
<RelativeLayout 
    android:layout_width="330dp" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    android:id="@+id/linear2" 
    android:layout_toRightOf="@id/linear1" 
> 
    <TextView 
     android:text="List2" 
     android:textSize="40px" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/seasons_text" 
    /> 
    <ListView 
     android:layout_height="wrap_content" 
     android:id="@+id/listView2" 
     android:layout_width="fill_parent" 
     android:layout_below="@id/seasons_text"   
    /> 
</RelativeLayout> 
<RelativeLayout 
    android:layout_width="330dp" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    android:id="@+id/linear3" 
    android:layout_toRightOf="@id/linear2" 
> 
    <TextView 
     android:text="List3" 
     android:textSize="40px" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/episodes_text" 
    /> 
    <ListView 
     android:layout_height="wrap_content" 
     android:id="@+id/listView3" 
     android:layout_width="fill_parent" 
     android:layout_below="@id/episodes_text" 
    /> 
</RelativeLayout> 

    </RelativeLayout> 

而這種佈局不相等單獨列表視圖,我試圖濮上佈局一些體重,但有一個我無法擺脫的小空間。

+0

確定有人已經告訴過你這個,但是它的糟糕的編程使用px而不是dp或sp。此外,即時通訊非常確定的重量沒有影響'RelativeLayout',但我可能是錯的 –

回答

0

對於正確使用layout_weight屬性...將父根佈局用作LinearLayout並將其方向設置爲水平。我想這可以解決你的問題。

+0

好吧,這是答案謝謝。 – Tsunaze

0

當您使用重量自動調整大小時,將layout_width更改爲0dip。此外,您可能需要將TextViews的layout_width更改爲fill_parent以與listview的寬度保持一致。

相關問題