Creating Apps with Material design--defining Shadows and Clipping views

Source: Internet
Author: User

View Reprint Please specify Http://blog.csdn.net/eclipsexys translation from developer Android, time haste, there are translation questions please note that, thank you

Defining shadows and Cuts

Material design introduces a deep UI element. Depth helps users understand the relative importance of each element. and focus on the task at hand.


A view. The elevation, represented by the Z-property, determines the size of its shadow: a larger shadow on a view with a higher Z-value. The number of views only casts shadows on the z=0 plane; they do not cast shadows on the following other views that place them and above the z = 0 plane.

Views with a higher Z-value block view with lower Z-values. However, because Z-values do not affect the size of the view.

Elevation is also very animated. The widget temporarily goes beyond the view plane to run certain operations.


Designate elevation to your views

Z-values in one view have two components, height and translation. Elevation is static components and translations are used for animations:

Z = elevation + translationZ


设置在布局定义视图的高度,使用android:elevation属性。设置在活动的代码视图的高度,使用View.setElevation()方法。 

要设置视图的转换。使用View.setTranslationZ()方法。 

新ViewPropertyAnimator.z()和ViewPropertyAnimator.translationZ()方法,使您能够轻松地制作动画的View elevation。欲了解很多其它信息,请參阅ViewPropertyAnimator和物业动画开发者指南的API參考。

 

您也能够使用StateListAnimator以声明方式指定这些动画。

这是情况下,状态变化触发动画,当用户按下一个button,像特别实用。欲了解很多其它信息,请參见动画视图状态更改。


Z值与X和Y值具有同样的測量单位。



You define the shadow of the View and outlines

The bounds of a view's background draw determine the default shape of its shadow. outlines represents the outer shape of the drawing object and limits the touch feedback of the ripple area.



Consider this view, with the definition of background drawing:

<textview    android:id= "@+id/myview" ...    android:elevation= "2DP"    android:background= "@drawable/myrect"/>

Background drawing is defined as a rectangle with rounded corners:

<!--res/drawable/myrect.xml--><shape xmlns:android= "Http://schemas.android.com/apk/res/android"       Android:shape= "Rectangle" >    <solid android:color= "#42000000"/>    <corners android:radius= "5DP"/ ></shape>

The view casts a shadow with rounded corners. Because background drawing defines the outline of the view. Provides a default shape that outlines the shadow of a view that you define yourself.


To define a view in your own defined outline code:


Extends the Viewoutlineprovider class.
Overrides the Getoutline () method.
Assigns a new outline to your view with the View.setoutlineprovider () method.



You can create oval and rectangular outlines using the method fillet in the outline class. The default schema provider's comments get a background outline from the view. To prevent the shadow from being shadowed, set its profile provider to NULL.



Cut view

Crop view, you can easily change the shape of the view. You can change the view consistency with other design elements or change the shape of the diagram in response to user input. You can clip to use the View.setcliptooutline () method or the outline area of Android: Cliptooutline property.

Only rectangles, rounded and rounded rectangular contours support clipping, as determined by the Outline.canclip () method.

Clip view to the drawn shape. Sets the background of the drawing view (as seen) and calls the View.setcliptooutline () method.

Clipping view is expensive operation, so do not animate. You use it to clip the shape of the view. To achieve this effect, use the display effect animation.







Creating Apps with Material design--defining Shadows and Clipping views

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.