Change ListView RowHeight programmatically in Xamarin Android

Corrado Cavalli
Corrado Cavalli
Published in
1 min readDec 9, 2015

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.

--

--

Corrado Cavalli
Corrado Cavalli

Senior Sofware Engineer at Microsoft, former Xamarin/Microsoft MVP mad about technology. MTB & Ski mountaineering addicted.