I am working on a project in Android Studio where I have a form on which I need to place a scroll function (scrollbar) however, when I apply it and execute the scroll it does not happen, no matter how much I try to scroll the screen it stays fixed.
below is the activity.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#33b8ff"
android:fillViewport="true"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/LOGO"
android:layout_width="287dp"
android:layout_height="77dp"
android:src="@drawable/logo"
android:translationX="20dp"
android:translationY="20dp" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Crear cliente"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="110dp"
android:translationY="50dp" />
<EditText
android:id="@+id/id"
android:layout_width="333dp"
android:layout_height="48dp"
android:background="@color/white"
android:ems="10"
android:hint="ID"
android:inputType="text"
android:layoutDirection="ltr"
android:textAlignment="gravity"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="40dp"
android:translationY="80dp" />
<EditText
android:id="@+id/tipoId"
android:layout_width="335dp"
android:layout_height="48dp"
android:background="@color/white"
android:ems="10"
android:hint="Tipo ID"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="40dp"
android:translationY="120dp" />
<EditText
android:id="@+id/nombre"
android:layout_width="335dp"
android:layout_height="48dp"
android:background="@color/white"
android:ems="10"
android:hint="Nombre"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="40dp"
android:translationY="160dp" />
<EditText
android:id="@+id/direccion"
android:layout_width="335dp"
android:layout_height="wrap_content"
android:background="@color/white"
android:ems="10"
android:hint="Direccion"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="40dp"
android:translationY="200dp" />
<EditText
android:id="@+id/telefono"
android:layout_width="335dp"
android:layout_height="wrap_content"
android:background="@color/white"
android:ems="10"
android:hint="Telefono"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="40dp"
android:translationY="240dp" />
<EditText
android:id="@+id/ciudad"
android:layout_width="335dp"
android:layout_height="wrap_content"
android:background="@color/white"
android:ems="10"
android:hint="Ciudad"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="40dp"
android:translationY="280dp" />
<EditText
android:id="@+id/formaPago"
android:layout_width="335dp"
android:layout_height="wrap_content"
android:background="@color/white"
android:ems="10"
android:hint="Froma de pago"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="40dp"
android:translationY="320dp" />
<EditText
android:id="@+id/correoFe"
android:layout_width="335dp"
android:layout_height="wrap_content"
android:background="@color/white"
android:ems="10"
android:hint="Correo para factura"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="40dp"
android:translationY="360dp" />
<Button
android:id="@+id/crearCliente"
android:layout_width="158dp"
android:layout_height="47dp"
android:text="Crear Cliente"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="40dp"
android:translationY="400dp"
android:visibility="visible" />
<Button
android:id="@+id/moduloFactura"
android:layout_width="158dp"
android:layout_height="47dp"
android:text="Modulo Facturas"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:translationX="230dp"
android:translationY="400dp"
android:visibility="visible" />
</LinearLayout>
</ScrollView>
This is the graphical representation
thanks
I have searched for a lot of information but nothing I have tried has worked.
You can fix the scrolling issue by replacing translationX and translationY with layout_margin. This change ensures proper spacing and scrollability within the ScrollView.
android:translationX="**dp"
android:translationY="**dp"
android:layout_marginTop="40dp"
android:layout_marginStart="40dp"