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?