Android Project Practice (): shadow effect on the background, android practice

Source: Internet
Author: User

Android Project Practice (): shadow effect on the background, android practice

 

The background of rounded corners should be frequently used:

A drawable resource file controls the corner rounded corner and solid fill color.

<shape xmlns:android="http://schemas.android.com/apk/res/android">    <corners android:radius="@dimen/dp_2"></corners>    <solid android:color="@color/standard_main"></solid></shape>

 

On this basis, the background of the rounded corner with shadow is implemented.

The Code is as follows:

<? Xml version = "1.0" encoding = "UTF-8"?> <Layer-list xmlns: android = "http://schemas.android.com/apk/res/android"> <! -- Shadow --> <! -- I personally think it is more vivid: top represents the shadow height below, and left represents the shadow width on the right. In fact, it is the corresponding offset. The color in solid is the shadow color, and the angle can be set. --> <item android: left = "4dp" android: top = "4dp"> <shape android: shape = "rectangle"> <gradient android: angle = "270" android: endColor = "#0F000000" android: startColor = "#0F000000"/> <corners android: bottomLeftRadius = "@ dimen/dp_4" android: bottomRightRadius = "@ dimen/dp_14" android: topLeftRadius = "@ dimen/dp_4" android: topRightRadius = "@ dimen/dp_4"/> </shape> </item> <! -- Background --> <! -- Image expression: bottom indicates that the background part is above the shadow height, and right indicates that the background part is beyond the shadow width (corresponding offset) on the left. --> <item android: bottom = "3dp" android: left = "@ dimen/dp_0.5" android: top = "@ dimen/dp_0.5" android: right = "3dp"> <shape android: shape = "rectangle"> <gradient android: angle = "270" android: endColor = "# FFFFFF" android: startColor = "# FFFFFF"/> <corners android: bottomLeftRadius = "@ dimen/dp_4" android: bottomRightRadius = "@ dimen/dp_14" android: topLeftRadius = "@ dimen/dp_4" android: topRightRadius = "@ dimen/dp_4"/> </shape> </item> </layer-list>

Effect: You can see that there is a small gray shadow effect on both the right side and the lower side.

 

 

Background effects of listing items in actual products:

 

Is there an effect similar to cardview?

 

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.