Clipchildren and Cliptopadding

Source: Internet
Author: User

Suppose we want to do an effect, the top of the interface is a actionbar and translucent, Actionbar below is a ListView, in the initial state, the ListView is top in the Actionbar bottom position, But when the ListView scrolls, you can see the contents of the following ListView through Actionbar. As shown in the following two images:

Positive normal:

Roll Dynamic:

At first glance, is not very simple, as long as the setting of margintop or paddingtop can be, but the problem is only one of these two properties, the ListView can not scroll to the paddingtop or margintop part of the area, Some people say that can be solved with headerview, this is one of the methods, but only for this space use Headview a bit wasteful and will affect the position of onitemclick. So here are the two properties that can go to this effect, which is Android: Cliptopadding and Android:clipchildren, these two properties are not too many people to use, here to explain

Cliptopadding is whether the drawing area of the control is in padding, true if you set the padding so that the area is indented, clipchildren refers to whether the child control is more than the padding area, 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.

<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_he ight= "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.


Note: Transfer from: http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0317/2613.html



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.