Reputation: 6700
I have a ScrollView and a ConstraintLayout with some views inside, but it is not scrolling. I saw in other related questions some advice to add:
android:fillViewport="true"
to the layout and I ever tried with NestedScrollView and change the position of ScrollView, but nothing helps.
My fragment layout is:
<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"
android:fillViewport="true"
>
<android.support.constraint.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:id="@+id/layout_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:paddingEnd="?attr/listPreferredItemPaddingRight"
android:paddingStart="?attr/listPreferredItemPaddingLeft"
android:paddingTop="?attr/listPreferredItemPaddingLeft"
>
<TextView
android:id="@+id/lbl_style"
style="@style/HeadSection"
android:text="@string/label_style"
app:layout_constraintStart_toStartOf="@+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="@+id/txt_beer_description"/>
<TextView
android:id="@+id/lbl_short_style"
style="@style/Label"
android:text="@string/label_short_style"
app:layout_constraintStart_toStartOf="@+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="@+id/lbl_style_name"/>
<TextView
android:id="@+id/txt_short_style"
style="@style/Content"
app:layout_constraintStart_toStartOf="@+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="@+id/txt_style_name"
tools:text="American Dark Lager"/>
<TextView
android:id="@+id/lbl_style_name"
style="@style/Label"
android:text="@string/label_style_name"
app:layout_constraintStart_toStartOf="@+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="@+id/lbl_style"/>
<TextView
android:id="@+id/txt_style_name"
style="@style/Content"
app:layout_constraintStart_toStartOf="@+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="@+id/lbl_style"
tools:text="American-Style Dark Lager"/>
<TextView
android:id="@+id/lbl_style_category_name"
style="@style/Label"
android:layout_height="19dp"
android:text="@string/label_style_category_name"
app:layout_constraintStart_toStartOf="@+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="@+id/lbl_short_style"/>
<TextView
android:id="@+id/txt_style_category_name"
style="@style/Content"
app:layout_constraintStart_toStartOf="@+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="@+id/txt_short_style"
tools:text="North American Lager"/>
<TextView
android:id="@+id/lbl_beer"
style="@style/HeadSection"
android:layout_marginLeft="16dp"
android:layout_marginTop="4dp"
android:text="@string/label_detail_head_beer_info"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/lbl_beer_name"
style="@style/Label"
android:text="@string/label_detail_beer_name"
app:layout_constraintStart_toStartOf="@+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="@+id/lbl_beer"/>
<TextView
android:id="@+id/txt_beer_name"
style="@style/Content"
app:layout_constraintStart_toStartOf="@+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="@+id/lbl_beer"
tools:text="Heineken"/>
<TextView
android:id="@+id/lbl_beer_Description"
style="@style/Label"
android:text="@string/label_detail_beer_description"
app:layout_constraintStart_toStartOf="@+id/guideline_label_margins"
app:layout_constraintTop_toBottomOf="@+id/lbl_beer_name"/>
<TextView
android:id="@+id/txt_beer_description"
style="@style/Content"
android:layout_width="0dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline_content_margins"
app:layout_constraintTop_toBottomOf="@+id/lbl_beer_Description"/>
<android.support.constraint.Guideline
android:id="@+id/guideline_label_margins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="16dp"/>
<android.support.constraint.Guideline
android:id="@+id/guideline_content_margins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="120dp"/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
This layout is inflated in a fragment that is:
content_detail.xml:
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
And the root layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:id="@+id/layout_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/card_height_huge"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include
layout="@layout/content_detail"/>
</android.support.design.widget.CoordinatorLayout>
-- EDIT
there is a bug report about this behavior.
I found a bug that was supposed to be fixed, but some others users related still report the issue:
https://issuetracker.google.com/issues/37115702
-- EDIT
I rotate the phone, the txt_beer_description
TextView goes off the screen. So if I scroll the scroll works until the end of txt_beer_description, no more.
-- EDIT
style file is:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@android:color/black</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="SearchBeerItemBaseText">
<item name="android:gravity">start|center_vertical</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginStart">8dp</item>
</style>
<style name="SearchBeerItemTextPrimary" parent="SearchBeerItemBaseText">
<item name="android:textColor">@color/primary_text</item>
<item name="android:textSize">16sp</item>
</style>
<style name="SearchBeerItemTextSecundary" parent="SearchBeerItemBaseText">
<item name="android:textColor">@color/secondary_text</item>
<item name="android:textSize">14sp</item>
</style>
<style name="CollectionItemBaseText">
<item name="android:gravity">start|center_vertical</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="CollectionItemTextPrimary" parent="CollectionItemBaseText">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">15sp</item>
<item name="android:focusable">false</item>
<item name="android:focusableInTouchMode">false</item>
<item name="android:clickable">false</item>
</style>
<style name="CollectionItemTextSecundary" parent="CollectionItemBaseText">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">13sp</item>
</style>
<style name="SearchActivityPrimaryImage">
<item name="android:layout_width">56dp</item>
<item name="android:layout_height">56dp</item>
</style>
<style name="HeadSection">
<item name="android:layout_marginTop">16dp</item>
<item name="android:layout_marginBottom">8dp</item>
<item name="android:textStyle">bold</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/primary</item>
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Subhead</item>
</style>
<style name="Label">
<item name="android:textStyle">bold</item>
<item name="android:layout_marginTop">16dp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/primary_text</item>
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Body1</item>
</style>
<style name="Content" >
<item name="android:layout_marginTop">16dp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/secondary_text</item>
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Body1</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
</resources>
Upvotes: 3
Views: 2379
Reputation: 6700
The problem is related with the appbar:
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/card_height_huge"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
I shouldn't use app:layout_behavior in that.
Upvotes: 1
Reputation: 3259
In your ScorllView
, change layout_height to:
android:layout_height="wrap_content"
Upvotes: 1