在彼此下方创建2个FrameLayout

时间:2019-05-12 00:37:34

标签: c# android-fragments xamarin.android

我有一个问题...我想在彼此之间创建2个FrameLayout,所以我尝试了以下代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#071c3f">
    <FrameLayout
        android:id="@+id/ActionBarContainer"
        android:layout_width="match_parent"
        android:layout_height="75dp"/>
    <FrameLayout
        android:id="@+id/LayoutContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

现在显示第一个FrameLayout,但第二个FrameLayout在屏幕上不可见。

我在做什么错了??

1 个答案:

答案 0 :(得分:0)

android:orientation的默认值为水平。因此,如果设置android:layout_width="match_parent",则不会在水平方向看到第二个FrameLayout

  

我要在彼此之间创建2个FrameLayouts

添加android:orientation="vertical"将起作用:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#374233"
    android:orientation="vertical">
    <FrameLayout
        android:id="@+id/ActionBarContainer"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        >   

    </FrameLayout>

    <FrameLayout
        android:id="@+id/LayoutContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </FrameLayout>
</LinearLayout>
相关问题