Reputation: 6743
I have an activity like this:
Below the "Berapa jumlah kartu kredit" TextView, there's another TextView and Spinner, but cannot scroll further down.
My code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
android:background="@drawable/whitebg"
tools:context=".activity.Apply1Activity">
<androidx.core.widget.NestedScrollView
android:id="@+id/nsv1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintTop_toTopOf="parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvApply1_tv0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:text="Input informasi pengajuan pinjaman"
android:textStyle="bold"
android:textSize="18dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:id="@+id/tvApply1_Pekerjaan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginLeft="10dp"
android:text="Pekerjaan"
android:textSize="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvApply1_tv0"
/>
<Spinner
android:id="@+id/spinner_pekerjaan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvApply1_Pekerjaan"/>
<TextView
android:id="@+id/tvApply1_NamaPerusahaan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:text="Nama perusahaan atau toko"
android:textSize="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/spinner_pekerjaan"
/>
<EditText
android:id="@+id/edtApply1_NamaPerusahaan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="10dp"
app:layout_constraintTop_toBottomOf="@id/tvApply1_NamaPerusahaan" />
<TextView
android:id="@+id/tvApply1_Email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:text="Email"
android:textSize="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/edtApply1_NamaPerusahaan"
/>
<EditText
android:id="@+id/edtApply1_Email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:singleLine="true"
android:maxLines="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="10dp"
app:layout_constraintTop_toBottomOf="@id/tvApply1_Email" />
<TextView
android:id="@+id/tvApply1_MulaiKerja"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:text="Mulai bekerja sejak"
android:textSize="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/edtApply1_Email"
/>
<LinearLayout
android:id="@+id/ll_worksince"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvApply1_MulaiKerja">
<Spinner
android:id="@+id/spinner_month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:entries="@array/arr_bulan"
/>
<Spinner
android:id="@+id/spinner_year"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<TextView
android:id="@+id/tvApply1_StatusPekerjaan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:text="Status pekerjaan"
android:textSize="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/ll_worksince"
/>
<Spinner
android:id="@+id/spinner_status_pekerjaan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvApply1_StatusPekerjaan"/>
<TextView
android:id="@+id/tvApply1_Income"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:text="Penghasilan per bulan"
android:textSize="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/spinner_status_pekerjaan"
/>
<EditText
android:id="@+id/edtApply1_Income"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:singleLine="true"
android:maxLines="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="10dp"
app:layout_constraintTop_toBottomOf="@id/tvApply1_Income" />
<TextView
android:id="@+id/tvApply1_KK"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:text="Berapa jumlah kartu kredit"
android:textSize="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/edtApply1_Income"
/>
<Spinner
android:id="@+id/spinner_kk"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginLeft="10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvApply1_KK"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<Button
android:id="@+id/btnApply1_Lanjut"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="220dp"
android:background="@color/color_orange"
android:text="Lanjut"
android:textColor="@color/colorWhite"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/nsv1"
app:layout_constraintVertical_bias="1.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
How to fix this?
Upvotes: 2
Views: 646
Reputation: 6981
You need to change
I have updated your code and it's working now.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_white">
<!--change Nested scrollview constraint, width and height-->
<androidx.core.widget.NestedScrollView
android:id="@+id/nsv1"
android:layout_width="0dp"
android:layout_height="0dp"
android:fillViewport="true"
app:layout_constraintBottom_toTopOf="@+id/btnApply1_Lanjut"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
.....
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<Button
android:id="@+id/btnApply1_Lanjut"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_blue_pin"
android:text="Lanjut"
android:textColor="@color/color_white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/nsv1" />
</androidx.constraintlayout.widget.ConstraintLayout>
Upvotes: 1
Reputation: 607
Multiple options:
Since you do not have any nested scrolling content inside the root scroll view. Try converting NestedScrollView to Scroll View. or
a. remove top constraint from button and add bottom constraint to the app:layout_constraintBottom_toTopOf="@+id/btnApply1_Lanjut"
b. replace match_parent with 0dp to actually match the constraint for nestedScrollView. Like this android:layout_height="0dp"
Upvotes: 0
Reputation: 3486
Most possibly your NestedScrollView is not scrolling because you have set it's height to match_parent, Try with wrap_content it should work then.
Upvotes: 0