How to fix ConstraintLayout inside ScrollView is not scolling?

0

My App contains many buttons, which are shown under each other, two per row. I generate the buttons dynamically via Java, which are them shown in the ConstraintLayout.

<?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"
        android:fillViewport="true">


        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/rootLayout"
            >

            </androidx.constraintlayout.widget.ConstraintLayout>

    </ScrollView>

I have tried several layouts beside the ConstraintLayout, the TableView scrolling worked, however the button are not in the correct place then.

This is how the buttons are generated:

Button b = new Button(this);
            b.setText(myClass.getTitle());
            b.setTextColor(0xFFFFFFFF);
            b.setX(buttonX);
            b.setY(buttonY);
            b.setWidth(buttonWidth);
            b.setHeight(buttonHeight);
            conLayout.addView(b);
java
android
android-constraintlayout
asked on Stack Overflow Aug 24, 2019 by G. Singh • edited Aug 26, 2019 by G. Singh

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0