首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用嵌套的FrameLayouts排列多个android片段?

如何用嵌套的FrameLayouts排列多个android片段?
EN

Stack Overflow用户
提问于 2012-08-05 06:47:38
回答 1查看 1.5K关注 0票数 0

我想要显示一个简单的横向布局,一个列表片段在屏幕的左半部分,两个垂直对齐的片段在右侧。水平显示所有三个片段都很好,但我下面的布局只显示列表片段,而不显示右侧垂直LinearLayout内的其他两个片段。我的布局参数做错了什么?

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

    <fragment class="com.copperykeenclaws.gameplanner.TeamListFragment"
        android:id="@+id/team_list_fragment"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_weight="1"
        android:layout_width="0px"
        android:layout_height="wrap_content">
   </fragment>
   <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_weight="1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <FrameLayout android:id="@+id/team_details_frame" 
                android:layout_width="0px" 
                android:layout_height="wrap_content"/>
        <FrameLayout android:id="@+id/team_players_frame" 
                android:layout_width="0px" 
                android:layout_height="wrap_content"/>
    </LinearLayout>
</LinearLayout>

在FragmentTransactions中以编程方式替换FrameLayouts,它在全水平布局中工作得很好。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-05 07:03:59

team_details_frameteam_players_frame的宽度都是0px,所以它们不会显示。要么给它们一个layout_weight属性(尽管不鼓励使用嵌套的layout_weights,但我怀疑在您的情况下会有多大的性能影响),或者将它们设置为wrap_content或match_parent。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11812548

复制
相关文章

相似问题

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