Android 如何在同一布局中垂直加载两个片段?

Android 如何在同一布局中垂直加载两个片段?,android,android-layout,android-ui,android-framelayout,Android,Android Layout,Android Ui,Android Framelayout,我正在为我的大学安全行走项目制作一个应用程序,我正在尝试制作一个活动,该活动将显示一个地图片段,下面有一个按钮栏,上面有紧急呼叫按钮。我遇到的问题是,当我加载以下布局文件时,只显示地图片段,而不显示底部的按钮 注意:我在这个布局中也使用了一个导航抽屉,所以我已经包含了该代码,以防冲突 我已尝试更改两个父框架布局的布局宽度和布局高度值 我只能得到两个结果中的一个,一整页的地图,或者一整页的按钮(拉伸到顶部)。如果需要,我可以附加CallButtonFragment的布局,但它是一个水平线性布局,按

我正在为我的大学安全行走项目制作一个应用程序,我正在尝试制作一个活动,该活动将显示一个地图片段,下面有一个按钮栏,上面有紧急呼叫按钮。我遇到的问题是,当我加载以下布局文件时,只显示地图片段,而不显示底部的按钮

注意:我在这个布局中也使用了一个导航抽屉,所以我已经包含了该代码,以防冲突

我已尝试更改两个父框架布局的布局宽度和布局高度值 我只能得到两个结果中的一个,一整页的地图,或者一整页的按钮(拉伸到顶部)。如果需要,我可以附加CallButtonFragment的布局,但它是一个水平线性布局,按钮栏样式包含两个按钮


根据下面Android er naut的建议,我得到了以下结果: (这是一个改进,但按钮需要更大一点并适合屏幕的宽度。)

这个怎么样-

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<!-- The main content view -->

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" >

    <fragment
        android:id="@+id/titles"
        android:name="edu.purdue.SafeWalk.CallButtonFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>

</LinearLayout>


除了采用
相对长度外
采用
线性布局
并将其方向设置为垂直无变化,地图占据了整个屏幕。@vidia,即使您将
匹配父项
高度更改为其他值,使每个片段都没有全屏高?但是片段中的布局属性不适用于FrameLayout父项而不是全屏吗?我在AVD上试过了(我身上没有真正的电话线)因为AVD没有播放服务而崩溃了…哎呀。我回家后会测试它,但我相信我已经尝试了线性布局,但它不起作用。再试一次也无妨。我根据你的建议更新了我的答案。按钮现在正在显示,但它们需要更大一些。。。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<!-- The main content view -->

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" >

    <fragment
        android:id="@+id/titles"
        android:name="edu.purdue.SafeWalk.CallButtonFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>

</LinearLayout>