If I have a single item in an ArrayAdapter on a ListView, I would like to stretch that one item all over the ListView height (so I have the text of the one item in the center of the screen).
Like this:
This is really easily done with RecyclerView (the image above) but in my case I can't afford rebuilding ListView screens on RecyclerView now. I tried setting the height of the layout item to the screen height "match_parent" or in code, overriding the 80dp value. It didn't have any impact on my situation, the result looked like this:
this is how I am creating the ArrayAdapter:
string[] noResultsItem = { Resources.GetString(Resource.String.no_network) };
playlistListView.Adapter = new ArrayAdapter<string>(this, Resource.Layout.no_result_row, Resource.Id.textTop, noResultsItem);
This is the layout for the ArrayAdapter item:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="80dp"
android:id="@+id/noResultsRow">
<TextView
android:id="@+id/textTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textSize="18dip"
android:textColor="#ffffff"
android:text=""
android:gravity="center_horizontal" />
</RelativeLayout>
I can imagine a solution with hiding and showing the ListView and replacing it with a TextView that would be centered but I don't like that solution that much.