我想要显示一个简单的横向布局,一个列表片段在屏幕的左半部分,两个垂直对齐的片段在右侧。水平显示所有三个片段都很好,但我下面的布局只显示列表片段,而不显示右侧垂直LinearLayout内的其他两个片段。我的布局参数做错了什么?
<?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,它在全水平布局中工作得很好。
发布于 2012-08-05 07:03:59
team_details_frame和team_players_frame的宽度都是0px,所以它们不会显示。要么给它们一个layout_weight属性(尽管不鼓励使用嵌套的layout_weights,但我怀疑在您的情况下会有多大的性能影响),或者将它们设置为wrap_content或match_parent。
https://stackoverflow.com/questions/11812548
复制相似问题