Xamarin.Android应用程序的ListView未滚动
我在我的页面上放置了一个谷歌地图的片段标记和一个列表视图,列表视图被地图下面的线性布局标记包围。有人知道为什么我的列表视图没有滚动吗。我将listview fastscrollenabled设置设置为true,但它仍然没有滚动Xamarin.Android应用程序的ListView未滚动,android,listview,xamarin,xamarin.android,Android,Listview,Xamarin,Xamarin.android,我在我的页面上放置了一个谷歌地图的片段标记和一个列表视图,列表视图被地图下面的线性布局标记包围。有人知道为什么我的列表视图没有滚动吗。我将listview fastscrollenabled设置设置为true,但它仍然没有滚动 var locationService = new LocationService(_geoCoder); listView.Adapter = new ListOfLocationAdapter(this, locationService.G
var locationService = new LocationService(_geoCoder);
listView.Adapter = new ListOfLocationAdapter(this, locationService.GetLatLongOfAddresses());
this.listView.FastScrollEnabled = true;
这是我用于布局的XAML
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="2"
android:columnCount="1">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="300dp"
class="com.google.android.gms.maps.MapFragment" />
<LinearLayout
android:id="@+id/linearLayout1"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/List"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:cacheColorHint="#FFDAFF7F"/>
</LinearLayout>
</GridLayout>
以下是listadapter代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:orientation="vertical"
android:background="#ffffff">
<LinearLayout
android:id="@+id/Text"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="vertical">
<TextView
android:id="@+id/CustomerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="20dip"
android:textStyle="italic"
android:paddingLeft="10dip" />
<TextView
android:id="@+id/Address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dip"
android:textColor="#000000"
android:paddingLeft="10dip" />
</LinearLayout>
</RelativeLayout>
我尝试删除relativelayout标记,但这对我没有任何帮助。将权重设置为listview并将高度设置为0dp。这将使其自动填充任何剩余空间,从而导致listview的内部项目滚动
<ListView
android:id="@+id/List"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:cacheColorHint="#FFDAFF7F" />
当我在片段和列表视图周围移动线性布局时,滚动开始工作。出于某种原因,线性布局显示了android布局的底部,使其看起来好像在我添加更多记录之前不会滚动
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="2"
android:columnCount="1">
<LinearLayout
android:id="@+id/linearLayout1"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="300dp"
class="com.google.android.gms.maps.MapFragment" />
<ListView
android:id="@+id/List"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:cacheColorHint="#FFDAFF7F" />
</LinearLayout>
</GridLayout>
我也有同样的问题。我只是将ListView的布局高度设置为匹配父项的值。这解决了我的问题。设置线性布局高度和方向Hi Ranjith…我添加了方向和高度,但仍无法滚动。检查我的答案并更新我。。如果不起作用的话Hi Ranjith…这也不起作用。我将添加我的listview适配器代码。我的个人建议->不要使用android布局。。使用Xamarin表单和XAML来设计listview,但这并没有解决它。我将更新帖子并将我的更改放在那里。会在帖子中发布我的listview适配器代码和xaml吗?