Reputation: 1
I wanted to display my super-tall image, so I tried to put it into ScrollView,and constraint it to the top of the screen so it would be possible to scroll through it. I imagined it would fill in the whole space on the screen but somehow there are two big blank spaces at the top and bottom of the image, so I can't pin the image right at the top
<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>
I tried messing up with all the constraints but I messed up. I think the constraints are the problem, but I can't figure it out. I tried also the "android:scaleType="fitStart"" thing but it breaks after some scrolling.
This is how it looks, there's just a background until you scroll down. After a while, the image finally appears.
Upvotes: 0
Views: 80
Reputation: 21
Open the "Design" view to see your screen side-by-side with he Component Tree and then click through the Component Tree to see which part of your layout is adding the space. You'll see blue borders around the element you have highlighted and you can use that to narrow down your problem.
Upvotes: 0