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

Android 是否可以使ScrollView中的第一个视图与屏幕尺寸匹配?,android,android-layout,scrollview,android-scrollview,Android,Android Layout,Scrollview,Android Scrollview,我用RecyclerView找到了这个。在我的RecyclerView中为特定项创建视图时,RecyclerView项布局与父项匹配 我想知道这是否也可以使用ScrollView 以下是我到目前为止所做的: ScrollView xml: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-au

我用RecyclerView找到了这个。在我的RecyclerView中为特定项创建视图时,RecyclerView项布局与父项匹配

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

以下是我到目前为止所做的:

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并动态/静态添加漫画项目。但是,作为第一个视图的主屏幕与屏幕设备不匹配

我只想问一下,这是否可能在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>


您应该使用“重力”attribute@Saret,你能举个例子吗?我仍然在努力理解重力在这里的作用,而事实上我是在要求维度。对不起,我指的是“重量”而不是重力。您可以在listitem\u comic\u菜单的相对布局中添加android:weight=“1”。好吧,saret!那很好。我早上第一件事就得检查一下!谢谢@Saret成功了谢谢你!它是正确的,你可以把你的评论作为答案发表,这样我就可以接受它作为正确的答案。谢谢它的布局重量对不起,我复制过了,过得太快了:\