Android:cliptopadding and Android:clipchildren

Source: Internet
Author: User

Suppose we want to do an effect, the top of the interface is a actionbar and is translucent, Actionbar below is a ListView, in the initial state,

The ListView is top in the bottom position of the actionbar, but when the ListView scrolls through the Actionbar you can see the following ListView

Content. As shown in the following two images:

Positive normal:

Roll Dynamic:

At first glance, it is not very simple, just set a margintop or paddingtop, but the problem is that only one of these two attributes,

The ListView can not roll to the paddingtop or margintop part of the area, some people say that it is possible to use the Headerview to solve, which is its

In one way, but only for this duty-free use of headview is a bit wasteful and will affect the position of onitemclick. So here's the introduction to this.

Effect of the two properties, is android:cliptopadding and Android:clipchildren, these two properties are not too many people use, here explain

Cliptopadding is whether the drawing area of the control is inside the padding, true if you set the padding so that the area is drawn to

Clipchildren refers to whether the child control exceeds the padding area, which is true by default, so the default setting is padding

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.

< ListView     android:layout_gravity = "Center_vertical"     android:id= "@+id/list"    android:clipchildren= "false"     android:cliptopadding= "false"    android:paddingtop= "50dip"     Android:layout_width = "Match_parent"     android:layout_height= "match_parent">

Actionbar Translucent is not detailed, as long as set Actionbaroverlay to true and set a translucent background for actionbar.

This attribute RecyclerView also has, is the same meaning.

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.