java - 框架布局未显示在主要 Activity 中

标签 java android layout android-framelayout

这是我的activity_main.xml

<?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">

    <include android:id="@+id/toolbar"
        layout="@layout/toolbar"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_below="@+id/toolbar">

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

    </LinearLayout>


</LinearLayout>

我的toolbar.xml:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary" />

我发送到fragment_content的 fragment :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#ffffff">

    <android.support.v4.widget.SwipeRefreshLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/swipe_container"
        android:layout_below="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

     <!-- Listview -->
    <ListView
        android:id="@+id/lvEvent"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#FFFFFF"
        android:divider="#D0D0D0"
        android:dividerHeight="0.5dp"
        android:showDividers="middle"/>

    </android.support.v4.widget.SwipeRefreshLayout>

</RelativeLayout>

现在工具栏出现了,我可以用它执行操作,但我的框架布局中没有任何内容?如果我删除包含(工具栏),那么我可以看到框架布局中的内容。有人知道我做错了什么吗?

最佳答案

鉴于您已将工具栏的高度设置为 wrap_content,我假设您想要垂直布局,但您的顶级 LinearLayout 设置为水平。将方向更改为垂直

关于java - 框架布局未显示在主要 Activity 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27040353/

相关文章:

java - 在实体类中定义一个不是列的变量

Android:如何在首选项 fragment 中显示标题栏

java - 带有部分的 ListView 中的 Itemclick 事件

layout - 在Flutter中,如何使用FittedBox调整行内文本的大小?

java - Android - Editbox Drawable 左边没有正确填充

java - 程序与 CountDownTimer 配合得很好,直到还剩 3 秒,然后它调用两次

android - 无法生成签名的APK。重复的条目:DragAndDropPermissionsCompat.class

html - 带有 CSS 的倾斜列

android - 如何将 Android XML 布局文件组织到文件夹中

java - IntStream 什么时候真正关闭? SonarQube S2095 是 IntStream 的误报吗?