I have a ListView that with alphabetical headers for each letter. I also have an index function that brings the letter headers to the top of the screen.
My problem is when I reach the end of the list setSelection is unable to bring the last few headers to the top because it will not scroll past the end of the list.
My question is this: Is there a way to add a blank space to the end of the screen dependent on screen size? I would like to scroll until the last item in the list is at the top of the listView.
The easiest way to add space is to add padding in xml and set clipToPadding:"false"
.
RecyclerView
<android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="20dp" android:paddingBottom="20dp" android:clipToPadding="false"/>
ListView
<ListView android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="20dp" android:paddingBottom="20dp" android:clipToPadding="false"/>
ScrollView
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="20dp" android:paddingBottom="20dp" android:clipToPadding="false"/>
This specifically adds the blank space to top and bottom but hide the space when you scroll the view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With