Android and androidstudio

Source: Internet
Author: User

Android and androidstudio
CollapsingToolbarLayout is a new control provided by google in its design libiary. The effect is similar to the following: the toolbar is transparent and has a background image and a large title. As the page slides up, the title is gradually scaled to the toolbar, when the background image slides to a certain extent, it becomes the toolbar color. This is a folding effect.

 

Introduction: dependencies {compile 'com. android. support: cardview-v7: 24.1.0 '// cardview compile 'com. android. support: design: 24.1.0 'compile 'com. android. support: appcompat-v7: 24.1.0 '} common xml attributes: 1) contentScrim: displays the subject color when the Toolbar shrinks to a certain extent. That is, the color of the Toolbar. 2) title: When titleEnable is set to true, the title is displayed when the toolbar is expanded. When the toolbar is scaled down, the title is displayed as the title above the toolbar. 3) scrimAnimationDuration: This attribute controls the animation duration of color changes when the toolbar is shrunk. That is, the time required for the animation to change the color to the color specified by contentScrim. 4) expandedTitleGravity: Specifies the position of the title when the toolbar is expanded. Similarly, there are expandedTitleMargin and collapsedTitleGravity attributes. 5) collapsedTitleTextAppearance: Specifies the title Font style when the toolbar is scaled down. Similar to expandedTitleTextAppearance. In general development, CollapsingToolbarLayout does not appear in the layout file, but as a child element of CoordinatorLayout, another control. What is CoordinatorLayout? In fact, the CoordinatorLayout control is very powerful and can implement multiple functions for its child elements. A common usage is to set A layout_scrollFlags attribute for A child element, then, set another child element B to the property of layout_behavior = "@ string/appbar_scrolling_view_behavior". This child element B is generally a slide control, such as RecyclerView and NestedScrollView, then, when child element B slides, child element A will make different changes based on its layout_scrollFlags attribute value. Therefore, we need to set the layout_scrollFlags attribute for CollapsingToolbarLayout. Layout_scrollFlags: * scroll: set this flag for all controls that want to slide. If this flag is not set, the View will remain unchanged. * EnterAlways: After this flag is set, if the View slides out of the screen, the View appears immediately as your finger slides down. This is another scenario. * EnterAlwaysCollapsed: If minHeight is set and this flag is set, the view will progress the screen at the minimum height, and the full height will be expanded when the sliding control slides to the top. * ExitUntilCollapsed: the current View is reduced when sliding up. However, the view can be fixed on the top. Layout_collapseMode: * pin: the View with this flag stays at the top of the page while the page is rolling. For example, the Toolbar can be fixed at the top * parallax: A View with this flag indicates that the page can be rolled at the same time. Layout_collapseParallaxMultiplier is an attribute associated with the phase of the flag. It is a parallax factor, indicating a difference between the View and the page's scroll speed, resulting in a relatively scrolling effect.

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.