Design an interface, the entire interface contains a ListView, but the ListView is not fully filled with the screen, as follows:
Layout may be designed like this
<linearlayout xmlns:android="Http://schemas.android.com/apk/res/android" Xmlns:tools="Http://schemas.android.com/tools"android:layout_width="Match_parent" android:layout_height="Match_parent"android:background="#2262" android:orientation="vertical" > <ListViewandroid:id="@+id/listview"android:layout_width="Match_ Parent "android:layout_height="match_parent "android:layout_marginleft=" 16DP "android:layout_marginright=" 16DP "android:paddingtop=" 16DP " > </ListView></linearlayout>
But here's the problem: the top can't be filled when scrolling
It's time to
android:cliptopadding and Android:clipchildren
Official documents:
cliptopadding: Whether the drawing area of the control is inside the padding and the value is true padding the area that is drawn does not include the padding area;
Define whether a child is limited to the boundaries within the drawing.
Clipchildren: When the padding of ViewGroup is not 0 o'clock, define viewgroup whether the child's padding is clipped.
These two properties are true by default, so in the case of padding, the default scrolling is within the padding, to achieve the above effect mainly set the two properties false then this way the control can be drawn to the padding area.
The modified code
<linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns:tools =" Http://schemas.android.com/tools " android:layout_width = "match_parent" android:layout_height =" match_parent " android:background =" #2262 " Android:orientation =; <ListViewandroid:id="@+id/listview"android:layout_width="Match_ Parent "android:layout_height="match_parent "android:layout_marginleft=" 16DP "android:layout_marginright=" 16DP "android:cliptopadding=" false " android:paddingtop="16DP" > </ListView></linearlayout>
Look at the effect again
Padding with plot area--android:cliptopadding and Android:clipchildren