【问题标题】:Framelayout doesn't show up in main activityFramelayout 未显示在主要活动中
【发布时间】:2014-11-20 13:04:51
【问题描述】:

这是我的 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 的片段:

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

现在工具栏出现了,我可以用它做一些动作,但是我的 Framelayout 中什么都没有?如果我删除包含(工具栏),那么我可以在我的 Framelayout 中看到内容。有人知道我做错了什么吗?

【问题讨论】:

    标签: java android layout android-framelayout


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-11
      相关资源
      最近更新 更多