I am trying to build a simple note app. And i would like to add checkbox functional.
I keep note part and checkbox recyclerview in scrollview to make it a one scrollable element. But when there are too many text in note or to many lines in checklist i can't see the whole note text. Just cant scroll to top of note. How can i fix it?
<?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="wrap_content"
android:padding="16dp">
<ScrollView
android:id="@+id/add_note_note_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/add_note_options"
android:layout_alignParentTop="true"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/add_note_options">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/add_note_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:hint="@string/note_hint"
android:scrollbars="none" />
</com.google.android.material.textfield.TextInputLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/add_note_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</LinearLayout>
</ScrollView>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/add_note_options"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="16dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="16dp">
<TextView
android:id="@+id/add_note_checkbox_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/checkbox"
android:textColor="@color/black"
app:drawableTopCompat="@drawable/ic_check_deactive"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/add_note_reusable_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:gravity="center"
android:text="@string/reusable"
android:textColor="@color/black"
app:drawableTopCompat="@drawable/ic_reusable_deactive"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/add_note_checkbox_item"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/add_note_progress_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:gravity="center"
android:text="@string/progress"
android:textColor="@color/black"
app:drawableTopCompat="@drawable/ic_progress_deactive"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/add_note_reusable_item"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/add_note_ok"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:text="@android:string/ok"
android:textColor="@color/black"
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Use android:layout_marginTop="80dp"
in LinearLayout
, change as require .
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:orientation="vertical">