java - Textview 不显示在 FrameLayout 中

标签 java android android-layout android-framelayout

我在另一个 linearlayout 中有一个 linearlayout 和一个 textview。显示了里面的 linearlayout,但问题是最后一个 textview 没有显示。为什么?

我有一个 LinearLayout 和一个 FrameLayout 以及一个 SwipeRefreshLayout 和一个 TextVeiw,但问题是当我在应用程序中模拟时,TextView 没有显示。这是为什么?

<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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".SearchResults">

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:id="@+id/content">


    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">



        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="50dp"
            android:text="EXAMPLE TEXT" />


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


</FrameLayout>

下图...

enter image description here

最佳答案

使用此代码更改您的 xml 文件

<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:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SearchResults">

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


        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/swipeContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_marginTop="50dp"
                android:text="EXAMPLE TEXT" />
        </android.support.v4.widget.SwipeRefreshLayout>
    </FrameLayout>
</LinearLayout>

关于java - Textview 不显示在 FrameLayout 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51128069/

相关文章:

java - Web Developer 想学习桌面编程

java - Android xml 中的嵌套数组

java - Android Textview 中的条件字符串与未评估数据绑定(bind)

android - fill_parent 不适用于 ScrollView 中的 RelativeLayout

android - ScrollView 无法正确调整自身大小

java - 如何将zip文件写入httpresponse

java - 当 Intellij 插件正确构建代码时,ANTLR4 解析器出现错误

java - 谁来加载 java.lang.ClassLoader?

android - 在 Android 中通过蓝牙接收 xml 字符串时出错

java - 如何在打开应用程序时读取文本文件?