我对Xoom平板电脑的布局有问题。基本上,我想要一个片段( ListView )在左边,另一个片段在ListView片段的右边。但是,我在这方面有两个问题。
首先,我不想硬编码列表视图片段的android:layout_width,它被设置为200dip (参见下面的代码)。我试过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>发布于 2011-09-15 04:50:55
您可以设置每个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没有占据整个屏幕。您是否支持largeScreens,清单中有一个设置。
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true">
</supports-screens>https://stackoverflow.com/questions/5759155
复制相似问题