首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xoom平板电脑的相关布局问题

Xoom平板电脑的相关布局问题
EN

Stack Overflow用户
提问于 2011-04-23 03:21:11
回答 1查看 423关注 0票数 1

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

首先,我不想硬编码列表视图片段的android:layout_width,它被设置为200dip (参见下面的代码)。我试过wrap_content,fill_parent,但它对我不起作用。

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

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

~谢谢!

代码语言:javascript
复制
<?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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-15 04:50:55

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

代码语言:javascript
复制
<?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,清单中有一个设置。

代码语言:javascript
复制
<supports-screens 
    android:resizeable="true" 
    android:smallScreens="true" 
    android:normalScreens="true" 
    android:largeScreens="true"  
    android:anyDensity="true">
</supports-screens>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5759155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档