滚动布局不会显示我的观点之一?

Scroll layout wouldn't show one of my views?

我想要以下布局:

但是当我 运行 代码时,包含相对布局和图像的第一个线性布局正确显示。 然后是 "view pager" 但它不在屏幕上。 然后还有一个文本框和一个按钮。

那么为什么我的查看寻呼机不见了?

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical"
    tools:ignore="NestedWeights,ContentDescription" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="5" >

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3"
            android:src="@drawable/sp_page_name"
            tools:ignore="ContentDescription" />

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:padding="@dimen/product_views_horizontal_padding"
            tools:ignore="NestedWeights" >
        </RelativeLayout>
    </LinearLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager_sharepoint"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:contentDescription="@string/TODO"/>

    <TextView
        android:id="@+id/sharepoint_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/sharepoint_description"
        tools:ignore="SelectableText" />
    <ImageButton 
        android:id="@+id/sp_more_info"
        android:layout_width="70dp"
        android:layout_height="30dp"
        android:background="@drawable/more_info_icon"
        android:layout_gravity="left"
        android:onClick="sp_more"/>

    </LinearLayout>
</ScrollView>

您的 ViewPager 的高度是 android:layout_height="wrap_content"

因此,如果您的 ViewPager 不包含其他视图,它将不可见。

好吧,我发现滚动视图不能很好地协同工作。 对于我的布局,我通过将 viewpager 的高度和宽度更改为静态大小来解决问题。实际上,我在 dimen.xml 文件中为不同的屏幕尺寸定义了一些不同的尺寸,并将它们用于我的视图寻呼机的高度和宽度。 这是代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical"
    tools:ignore="NestedWeights,ContentDescription" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="5" >

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3"
            android:src="@drawable/sp_page_name"
            tools:ignore="ContentDescription" />

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:padding="@dimen/product_views_horizontal_padding"
            tools:ignore="NestedWeights" >
        </RelativeLayout>
    </LinearLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager_sharepoint"
        android:layout_width="@dimen/viewpager_width"
        android:layout_height="@dimen/viewpager_height"
        android:contentDescription="@string/TODO"/>

    <TextView
        android:id="@+id/sharepoint_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/sharepoint_description"
        tools:ignore="SelectableText" />
    <ImageButton 
        android:id="@+id/sp_more_info"
        android:layout_width="70dp"
        android:layout_height="30dp"
        android:background="@drawable/more_info_icon"
        android:layout_gravity="left"
        android:onClick="sp_more"/>

    </LinearLayout>
</ScrollView>