簡體   English   中英

使用listviews xamarin android滾動線性布局

[英]Scroll linear layout with listviews xamarin android

<?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>

我有簡單的線性布局,有兩個列表視圖和一個ScrollView內的按鈕。 我需要滾動線性布局。 但現在我觀看完整的第一個列表視圖並滾動第二個列表視圖。 我無法看到我的按鈕。 填充列表視圖代碼:

 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; 

如何滾動精確的線性布局? 謝謝。

這里真正的問題與Android如何對ScrollViewListView做出反應有關。 不建議用戶將這些操作放在一起,因為設備無法識別要滾動的視圖, ScrollView將攔截ListView觸摸。 真正的解決方案是將所有內容組合成一個ListView (甚至更好的可能是RecyclerView 文檔 )。 兩個ListViews實際上是不必要的,並且可以在一個中完成自定義適配器。 然后, ScrollView也變得過時了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM