1
votes
<?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:fillViewport="true">

  <LinearLayout
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

<ListView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:id="@+id/firstLV"/>

<ListView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:id="@+id/secondLV"/>

<Button 
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="button"/>
  </LinearLayout>
</ScrollView>

I have simple linear layout with two listviews and one button inside ScrollView. I need to scroll linear layout. But now i watch full first list view and scrolled second listview. And I can't watch my button. Code for fill listviews:

 ListView firstListView = (ListView)FindViewById(Resource.Id.firstLV);
        ListView secondListView =   (ListView)FindViewById(Resource.Id.secondLV);
        string[] dataList = { "A", "B", "C", "D", "E" };
        ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, dataList);
        firstListView.Adapter = adapter;
        secondListView.Adapter = adapter; 

How can I scroll exactly linear layout? Thank.

1

1 Answers

0
votes

The real problem here has to do with how Android reacts with a ListView inside a ScrollView. It is not recommended for a user to have these actions together because the device has trouble recognizing which views to scroll and the ScrollView will intercept touches from the ListView. The real solution would be to combine everything into one ListView (or even better potentially a RecyclerView documentation). Two ListViews are really unnecessary and with a custom adapter can be done in one. Then, the ScrollView also becomes obsolete.