2011-04-22 74 views
1

我遇到了Xoom平板电脑布局问题。基本上,我想要一个片段(ListView)在左侧,另一个片段到ListView片段。但是,我在这方面有两个问题。Xoom平板电脑的相对布局问题

首先,我不想硬编码设置为200dip(请参阅下面的代码)的listview片段的android:layout_width。我尝试了wrap_content,fill_parent但它没有为我工作。

其次,此UI不会在整个屏幕上呈现。它只捕获整个平板电脑屏幕的一小部分。即使从fill_parent到其他值的硬编码也没有任何影响。

代码如下所示。我真的很感谢在这个问题上的任何帮助。

〜谢谢!!

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

    <fragment class="com.example.android.apis.app.FragmentLayout$TitlesFragment" 
     android:id="@+id/titles" android:layout_width="200dip" 
     android:layout_alignParentLeft="true" 
     android:layout_height="match_parent" /> 

    <FrameLayout android:id="@+id/details" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_alignParentRight="true" 
     android:layout_toRightOf="@id/titles" 
     android:background="?android:attr/detailsElementBackground" /> 
</RelativeLayout> 

回答

1

而不是硬编码,您可以设置每个framelayout的布局权重。即

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

    <FrameLayout 
    android:id="@+id/items_layout" 
    android:layout_weight="1" 
     android:layout_width="0px" 
     android:layout_height="match_parent" 
     android:background="?android:attr/detailsElementBackground" /> 

    <FrameLayout 
    android:id="@+id/details_layout" 
    android:layout_weight="2" 
     android:layout_width="0px" 
     android:layout_height="match_parent" 
     android:background="?android:attr/detailsElementBackground" /> 

不知道为什么你的UI是不是占用整个屏幕。你是否支持大屏幕,清单中有一个设置。

<supports-screens 
    android:resizeable="true" 
    android:smallScreens="true" 
    android:normalScreens="true" 
    android:largeScreens="true" 
    android:anyDensity="true"> 
</supports-screens> 
+0

非常感谢你布拉德利的回复。 – user720986 2011-09-15 05:13:12