是否可以使 ScrollView 中的第一个视图与屏幕尺寸匹配?

Is it possible to make the first view in ScrollView match dimensions to screen?

我可以使用 RecyclerView 以某种方式做到这一点。当我在我的 RecyclerView 中为特定项目创建视图时,recyclerview 项目布局与父级匹配。

我想知道这是否也可以使用 ScrollView?

这是我目前所做的:

滚动视图xml:

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/scrollview_homescreen"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

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

        <include layout="@layout/listitem_comic_menu"/>

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

        </LinearLayout>

    </LinearLayout>

</ScrollView>

内容:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativelayout_homescreen"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/imageview_menu_bg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:adjustViewBounds="true" />

    <ImageView
        android:id="@+id/imageview_menu_title_bg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/starwars_webtoon_home_1_logo"
        android:scaleType="fitXY"
        android:adjustViewBounds="true" />

    <Button
        android:id="@+id/button_start_reading"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_above="@+id/button_menu"
        android:layout_marginBottom="18dp"
        android:text="@string/button_start_reading"
        android:gravity="start"
        android:drawableRight="@drawable/ic_keyboard_arrow_right_black_24dp"
        android:drawableEnd="@drawable/ic_keyboard_arrow_right_black_24dp"
        android:background="@drawable/button_bg"
        android:textSize="18sp"
        android:layout_marginStart="12dp"
        android:layout_marginLeft="12dp"
        android:layout_marginEnd="12dp"
        android:layout_marginRight="12dp" />

    <Button
        android:id="@id/button_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="28dp"
        android:text="@string/button_menu"
        android:textSize="18sp"
        android:textColor="#FFFFFF"
        android:drawableLeft="@drawable/ic_menu_white_24dp"
        android:drawableStart="@drawable/ic_menu_white_24dp"
        android:background="?android:attr/selectableItemBackground" />

</RelativeLayout>

那我想做什么?基本上这是用于漫画列表。第一项应该是主屏幕、几个按钮和整个应用程序徽标。下一个项目应该显示列表(我有 40 个相同宽度和高度的项目)和一个页脚。

我需要我的主屏幕与父屏幕相匹配。因此,当我滚动最上面的部分时,第一个项目(第一个视图,即主屏幕)会填满整个设备屏幕。

我能够在 RecyclerView 上做到这一点并且看起来不错。我遇到了一些困扰我的问题,我必须广泛解决这些问题,以至于我正在破解系统,我意识到 RecyclerView 并不是这种情况下的最佳布局。我目前正在决定是否切换到 ScrollView 并 dynamically/statically 添加漫画项目。但是,作为第一个视图的主屏幕与屏幕设备不匹配。

我想问一下这是否可以在 ScrollView 中完成?

谢谢!

使用权重属性:

<LinearLayout
  android:id="@+id/linearlayout_homescreen"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_weight="1"
  android:orientation="vertical">

        <include layout="@layout/listitem_comic_menu"/>

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

        </LinearLayout>

</LinearLayout>