I am trying to put recyclerView with a screen (Fragment) that has textView.
The .xml file of the fragment i'm trying to add to:
<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"
tools:context=".ui.ways.WaysFragment">
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/ways_quote"
android:layout_marginTop="@dimen/card_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:textSize="18sp"
android:layout_marginBottom="10dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="0dp"
android:layout_height="0dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
tools:listitem="@layout/custom_ways_item" />
</androidx.constraintlayout.widget.ConstraintLayout>
I will try to describe the appearance (result) of what I tried to do with code and words, rather than pictures, I think it will be easily understood that way.
At first I added textView and just put the recyclerView under it. And the result(appearance on my test device) I got look like:
Layout:
....
TextView:
....
ScrollView:
....
and the contents of my recyclerView
By this I mean, the textView doesn't scroll but the recyclerView does.
Next I put the textView
and recyclerView
inside the a single scrollView
. But the textView scrolls seperately from the recyclerView, as if textView and recyclerView were in different scrollView.
the result(appearance on my test device) I got look like:
Layout:
....
ScrollView:
....
TextView:
....
ScrollView:
....
and the contents of my recyclerView
And my desired Appearances, is:
Layout:
....
ScrollView:
....
TextView:
....
Contents of my recyclerView:
....