jLab19
jLab19

Reputation: 27

Android ScrollView doesn't scroll to bottom

This is part of my Layout:

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorGrey20"
        tools:context=".View.Activities.MainActivity">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="24dip"
                android:orientation="horizontal">

...

My ScrollView doesn't scroll to bottom

Screenshot

The last icon and description are never reached. What would I change in my layout?

Upvotes: 1

Views: 2923

Answers (4)

Petter Hesselberg
Petter Hesselberg

Reputation: 5498

I've had good results replacing

android:layout_height="wrap_content"

...with this:

android:layout_height="0dp"
android:layout_weight="1"

(I still have problems understanding the root cause.)

Upvotes: 0

Maxime Ashurov
Maxime Ashurov

Reputation: 554

Use paddings instead of margins on scrollview and its subviews and scrolling will be correct.

Upvotes: 2

Try this :

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="2dp"
    android:id="@+id/scrollview"
    android:stackFromBottom="true"
    android:transcriptMode="alwaysScroll">

Upvotes: 0

Ronish
Ronish

Reputation: 404

use

android:layout_height="fill_parent"

instead of "wrap_content" in your ScrollView

Upvotes: 2

Related Questions