Android (Lollipop/5.0) Material Design (4) defines shadow and cropping View

Source: Internet
Author: User

Android (Lollipop/5.0) Material Design (4) defines shadow and cropping View

Official Website: https://developer.android.com/intl/zh-tw/training/material/shadows-clipping.html

The Material design introduces a depth value to the UI element. depth helps you understand the relative importance of each element and focuses on the task at hand.

The elevation value of each View is equivalent to the z attribute, which determines the shadow size. The larger the value of z, the larger the shadow.

Views are projected only on the z = 0 plane; they are not projected on other Views placed under them and above.

Using Views with higher z values will block the use of Views with lower z values.

However, the Z value of a View does not affect the size of the View.

Elevation allows you to create an animation when the component needs to temporarily rise to the View plane for some operations.

Assign Elevation to Your Views specify Elevation in Views

The Z value contains two components: elevation and translation. Elevation is a static component. translation uses an animation: Z = elevation + translationZ.

Set elevation in layout and use the android: elevation attribute. Set in the Code and use the View. setElevation () method.

Set a View's translation and use the View. setTranslationZ () method.

ViewPropertyAnimator. z () and ViewPropertyAnimator. translationZ () make it easier for you to promote the elevation of Views.

You can also use StateListAnimator to specify the animation declaration method. This is particularly useful when the state changes trigger an animation, for example, when a user presses a button.

Customize View Shadows and Outlines custom View Shadows and Outlines

The border of the View's back image determines the default shadow image. A contour represents the external shape of a graphic object and defines the ripple areas used for touch feedback.
Reference: vce1xl7y0m4kpgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20141128/20141128084959108.png" alt = "">
Because the background image defines the outline of the View, a shadow with rounded corners is placed in the View. Provides a custom profile to override the default shadow image of the View. Custom outlines in the Code: · Inherit from ViewOutlineProvider · override getOutline () · use View. setOutlineProvider () to assign a new profile
Use some methods of the Outline class to create a rounded rectangle and an elliptical contour. The default outline provider contains the View's background profile. Blocks the projection of a View. You can set the ouline provider of the View to null. Clip Views CroppingCropping a view allows you to easily change the view shape. You can crop it to use other design elements, or change the View shape when responding to user input. You can crop the external contour area of the View and use the View. setClipToOutline () or android: clipToOutline attribute. Only rectangles, circles, and rounded rectangles support contour pruning, which is determined by the Outline. canClip () method. To crop an image into a shape, you must set the image as the View background and call View. setClipToOutline ().
Cropping is a luxury operation. Do not use dynamic images for cropping. To achieve this effect, you can use an animation to display it.

Related Article

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.