'Included layout with Scrollview Won't Scroll
The included layout is using a ScrollView as the root layout and it won't scroll. I tried using it with a relative layout and linear layout instead of the constraint layout. Any help would be appreciated.
fragment_station.xml
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".ui.station.view.StationFragment">
<ImageView
android:id="@+id/astro_image"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_gravity="center|end"
android:scaleType="centerCrop"
android:src="@drawable/sample_astro_asset"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="100dp"
app:cardCornerRadius="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/guideline">
<include layout="@layout/station_details"/>
</androidx.cardview.widget.CardView>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="335dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
station_details.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="30dp">
<TextView
android:id="@+id/station_details_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NGC 4651: The Umbrella Galaxy"
app:layout_constraintEnd_toStartOf="@id/guideline"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="NGC 4651: The Umbrella Galaxy" />
<TextView
android:id="@+id/station_details_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="2022-02-07"
app:layout_constraintEnd_toStartOf="@id/guideline"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/station_details_title"
tools:text="2022-02-07" />
<TextView
android:id="@+id/station_details_overview_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="Overview"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/station_details_date"
tools:text="Overview" />
<TextView
android:id="@+id/station_details_overview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="It is raining stars. What appears to be a giant cosmic umbrella is now known to be a tidal stream of stars stripped from a small satellite galaxy. The main galaxy, spiral galaxy NGC 4651, is about the size of our Milky Way, while its stellar parasol appears to extend some 100 thousand light-years above this galaxy's bright disk. A small galaxy was likely torn apart by repeated encounters as it swept back and forth on eccentric orbits through NGC 4651. The remaining stars will surely fall back and become part of a combined larger galaxy over the next few million years. The featured image was captured by the Canada-France-Hawaii Telescope (CFHT) in Hawaii, USA. The Umbrella Galaxy lies about 50 million light-years distant toward the well-groomed northern constellation Coma Berenices.Almost Hyperspace: Random APOD Generator"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/station_details_overview_label"
tools:text="It is raining stars. What appears to be a giant cosmic umbrella is now known to be a tidal stream of stars stripped from a small satellite galaxy. The main galaxy, spiral galaxy NGC 4651, is about the size of our Milky Way, while its stellar parasol appears to extend some 100 thousand light-years above this galaxy's bright disk. A small galaxy was likely torn apart by repeated encounters as it swept back and forth on eccentric orbits through NGC 4651. The remaining stars will surely fall back and become part of a combined larger galaxy over the next few million years. The featured image was captured by the Canada-France-Hawaii Telescope (CFHT) in Hawaii, USA. The Umbrella Galaxy lies about 50 million light-years distant toward the well-groomed northern constellation Coma Berenices.Almost Hyperspace: Random APOD Generator" />
<TextView
android:id="@+id/station_details_copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="Tamas Ladanyi"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/station_details_overview"
tools:text="Tamas Ladanyi" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="265dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="normal"
android:contentDescription="Like"
android:src="@drawable/ic_home_black_24dp"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="@id/guideline"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I've also tried solutions like fixing constraints, width, height, and fillViewPort.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
