Search code examples
javaandroid-emulatorscrollviewtouchpad

In my simulation of the prototype of my android app the scroll view (linear layout) is not scrolling


In my android app I have a linear layout within a scroll view but when I open the app in the emulator I can't scroll the scroll view.

I don't know if this could be the solution but I'm not working with a mouse but only with my touchpad and when I try the 2 finger scroll the emulator acts like if I was pressing the button. I have tried to put the fillViewport function in it but it is still not working.

<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".HomeScreen">

    <Button
        android:id="@+id/settingsNavigator"
        android:layout_width="0dp"
        android:layout_height="110dp"
        android:layout_marginTop="40dp"
        android:text="SETTINGS"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="0dp"
        android:layout_height="45dp"
        android:text="Not connected"
        android:textAlignment="center"
        android:textColor="#FF0000"
        android:textSize="30sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button5" />

    <Button
        android:id="@+id/button5"
        android:layout_width="0dp"
        android:layout_height="120dp"
        android:layout_marginTop="25dp"
        android:text="Button"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ScrollView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="55dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/settingsNavigator">

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

            <Button
                android:id="@+id/button15"
                android:layout_width="match_parent"
                android:layout_height="90dp"
                android:text="Button" />

            <Button
                android:id="@+id/button14"
                android:layout_width="match_parent"
                android:layout_height="90dp"
                android:text="Button" />

            <Button
                android:id="@+id/button13"
                android:layout_width="match_parent"
                android:layout_height="90dp"
                android:text="Button" />

            <Button
                android:id="@+id/button12"
                android:layout_width="match_parent"
                android:layout_height="90dp"
                android:text="Button" />

            <Button
                android:id="@+id/button11"
                android:layout_width="match_parent"
                android:layout_height="90dp"
                android:text="Button" />

            <Button
                android:id="@+id/button10"
                android:layout_width="match_parent"
                android:layout_height="90dp"
                android:text="Button" />
        </LinearLayout>
    </ScrollView>

</android.support.constraint.ConstraintLayout>

The app build is working just fine but the scroll is the only thing not working.


Solution

  • Ok, I actually figured it out myself quit quickly. Seems like I have asked this a lot to early without really thinking about it. Though the solution might help other people:

    I just put everything in another LinearLayout. That fixed the problem. Now only the bottom part is scrolling leaving the upper part untouched which is exactly what I wanted.