Padding with plot area--android:cliptopadding and Android:clipchildren

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.