I have a linear layout that looks something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear_layout"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
tools:context=".activities.EnrolStudentFormActivity">
<include
layout="@layout/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true" />
<ListView
android:id="@+id/list_view
android:layout_width="match_pare
android:layout_height="wrap_cont
android:divider="@null"
android:dividerHeight="0dp" />
</LinearLayout>
With a few ImageView
s, TextInputLayout
s and TextInputEditText
s in between. I want to make this layout scrollable. I tried to make it scrollable with ScrollView
and NestedScrollView
, but both of them messed the ListView
up.
I am also changing the ListView
contents dynamically and I have a few TextInputEditText
s inside TextInputLayout
s inside the ListView
. Resizing the ListView
doesn't help much, and I cannot click on the TextInputEditText
inside the ListView
. It seems that the ScrollView
captures the touch input.
Are there any workarounds that will let me have a ListView
inside a ScrollView
or make the linear layout scrollable while making the TextInputEditText
inside the ListView
usable?
Use RecyclerView
instead of ListView
and add NestedScrollView
on top:
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="
http://schemas.android.com/apk/res/android"
xmlns:http="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
tools:context=".activities.EnrolStudentFormActivity">
<include
layout="@layout/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true" />
<android.support.v7.widget.RecyclerView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:dividerHeight="0dp" />>
</LinearLayout>
and finally in your code add:
RecyclerView.setNestedScrollingEnabled(false);