有没有办法去除ScrollView中屏幕顶部和图像顶部之间的空间?

问题描述 投票:0回答:1

我想显示我的超高图像,所以我尝试将其放入 ScrollView 中,并将其限制在屏幕顶部,以便可以滚动它。我想象它会填满屏幕上的整个空间,但不知何故,图像的顶部和底部有两个大的空白空间,所以我无法将图像固定在顶部

<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/pozadid1"
    tools:context=".Lekce1Activity">

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <com.ortiz.touchview.TouchImageView
                android:id="@+id/image1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:src="@drawable/i1"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

我试图搞乱所有的限制,但我搞砸了。我认为限制是问题所在,但我无法弄清楚。我也尝试了“android:scaleType=”fitStart””的东西,但在一些滚动后它就中断了。

This is how it looks, there's just a background until you scroll down. After a while, the image finally appears.

android android-constraintlayout android-scrollview
1个回答
0
投票

打开“设计”视图以并排查看屏幕与组件树,然后单击组件树以查看布局的哪一部分正在添加空间。您会在突出显示的元素周围看到蓝色边框,您可以使用它来缩小问题范围。

© www.soinside.com 2019 - 2024. All rights reserved.