Corrado's Blog 2.0

Online thoughts of a technology funatic

Change ListView RowHeight programmatically in Xamarin Android

Here’s a quick code snippet that allows you to change the row height of an Android ListView in Xamarin

public override View GetView(int position, View convertView, ViewGroup parent) { View view = convertView ?? this.context.LayoutInflater.Inflate(Android.Resource.Layout.ActivityListItem, null); if (view.LayoutParameters == null) { view.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, 300); } else { view.LayoutParameters.Height = 300; } ...other code here... return view; }

Code resides inside ListView adapter, as you see, the magic is acting on view LayoutParameters property.

Hope it helps.

1 Comment “Change ListView RowHeight programmatically in Xamarin Android”

  1. [...] Change ListView RowHeight programmatically in Xamarin Android (Corrado Cavalli) [...]

    Pingback by Dew Drop – December 9, 2015 (#2148) | Morning Dew — 09/12/2015 @ 13:56

RSS feed for comments on this post. TrackBack URL

Leave a Response