2011-02-01 67 views
0

我是Android開發新手。我喜歡在「分割視圖」中開發應用程序(ipad具有內置框架)。我做了「WVGA800」橫向模式的示例,但對於多屏幕無法解決它。示例代碼:Android「拆分視圖」應用程序

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
android:id="@+id/widget30" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
> 
<LinearLayout 
android:id="@+id/widget32" 
android:layout_width="395dp" 
android:layout_height="fill_parent" 
android:background="#ff99ff99" 
android:orientation="vertical" 
android:layout_alignBottom="@+id/widget31" 
android:layout_toRightOf="@+id/widget31" 
> 
</LinearLayout> 
<LinearLayout 
android:id="@+id/widget31" 
android:layout_width="166dp" 
android:layout_height="fill_parent" 
android:background="#ff9999ff" 
android:orientation="vertical" 
android:layout_alignParentTop="true" 
android:layout_alignParentLeft="true" 
> 
</LinearLayout> 
</RelativeLayout> 

以上是樣本佈局。任何人可以建議我如何修復多個屏幕的「分割視圖」。

回答

4

根據我的經驗,RelativeLayout的是平如果您嘗試使用「toRightOf」屬性(您知道,相對於那些),則不會中斷。我不確定碎片是否會解決您的問題,因爲它們會替換您的LinearLayouts,而不是容器,問題在哪裏。

您可以使用包含兩個垂直LinearLayout(或片段,如果您願意的話)的水平LinearLayout進行此操作。您需要做的只是在用戶拖動分隔欄時相互更改兩個孩子的layout_weight屬性(在減少另一個時增加一個)。