How to keep a button in a fixed place when adding lines to the TextView above?

Viewed 21

In Android Studio I have a ScrollView and inside a layout with TextView, ImageView, another few objects and then a button. In my app everytime you click on the button, the TextView adds another line (up to a limit), how can I prevent the button changing its place in the layout when adding a new line? (All of the objects except for one TextView and the button are Invisble).

Preview: Layout preview

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    tools:context=".GameActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:orientation="vertical">

            <TextView
                android:id="@+id/levelTV"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Level 1"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/senTV"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="50dp"
                android:text="Sentence"
                android:textSize="24sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/transTV"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Translation"
                android:textAlignment="textStart"
                android:textSize="24sp" />

            <ImageView
                android:id="@+id/pic"
                android:layout_width="match_parent"
                android:layout_height="130dp"
                app:srcCompat="@android:drawable/btn_dialog" />

            <EditText
                android:id="@+id/picET"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="word in the pic"
                android:minHeight="48dp" />

            <ImageButton
                android:id="@+id/backBtn"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                app:srcCompat="@android:drawable/ic_input_delete"
                tools:ignore="SpeakableTextPresentCheck"
                android:onClick="back"/>

            <com.google.android.material.chip.ChipGroup
                android:id="@+id/bank"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"

                >

                <com.google.android.material.chip.Chip
                    android:id="@+id/word1"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:tag="0"
                    android:text="word1"
                    android:textAlignment="center"
                    android:theme="@style/Theme.MaterialComponents.Light" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word2"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:tag="1"
                    android:text="word2"
                    android:textAlignment="center"
                    android:theme="@style/Theme.MaterialComponents.Light" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word3"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:tag="2"
                    android:textAlignment="center"
                    android:theme="@style/Theme.MaterialComponents.Light"
                    tools:text="word3" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word4"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:tag="3"
                    android:text="word4"
                    android:textAlignment="center"

                    android:theme="@style/Theme.MaterialComponents.Light" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word5"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:tag="4"
                    android:textAlignment="center"
                    android:theme="@style/Theme.MaterialComponents.Light"
                    tools:text="word5" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word6"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:tag="5"
                    android:textAlignment="center"
                    android:theme="@style/Theme.MaterialComponents.Light"
                    tools:text="word6" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word7"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:tag="6"
                    android:text="word7"
                    android:textAlignment="center"
                    android:theme="@style/Theme.MaterialComponents.Light" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word8"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:tag="7"
                    android:text="word8"
                    android:textAlignment="center"
                    android:theme="@style/Theme.MaterialComponents.Light" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word9"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:tag="8"
                    android:text="word9"
                    android:textAlignment="center" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word10"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:tag="9"
                    android:text="word10"
                    android:textAlignment="center" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word11"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:tag="10"
                    android:textAlignment="center"
                    tools:text="word11" />

                <com.google.android.material.chip.Chip
                    android:id="@+id/word12"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:tag="11"
                    android:text="word12"
                    android:textAlignment="center" />

            </com.google.android.material.chip.ChipGroup>

            <Button
                android:id="@+id/checkBtn"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:backgroundTint="#80DEEA"
                android:onClick="check"
                android:text="הבא"
                android:textSize="16sp"
                android:textStyle="bold" />
        </LinearLayout>
    </ScrollView>

</LinearLayout
0 Answers
Related