In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to set shadow effect in Android". In daily operation, I believe many people have doubts about how to set shadow effect in Android. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to set shadow effect in Android". Next, please follow the editor to study!
Setting shadows on the controls will make the interface elements look better. Google provides us with a ready-made control CardView, which can be thought of as FrameLayout adding fillets and shadows on top of itself.
In this article, shadows are realized by setting the background for the control.
Create a new Drawable Resource File under res/drawable
Using layer-list layers means that multiple layers can be covered one layer at a time
Create a new gradient layer item as the background layer, mainly gradient,shape is used to define the shape, corners sets the angle, gradient defines the shape for the gradient fill, startColor start color, endColor end color, angle represents the direction angle. When angle=0, the gradient is from left to right. Then turn counterclockwise, from the bottom to the top when angle=90
Create a new layer, as the top layer, the principle of shadow realization is that the small display of the top layer reveals a part of the layer below. This requires setting the left, top, right and bottom properties of Item. The setting of these parameters is similar to setting margin, so you can have a shadow effect. Of course, for the effect, my parameters are a little exaggerated, only the shadows on the right and below are set. Solid sets the fill, and stroke sets the border, sets the color, and sets the width to see the border effect.
On the top layer, you can still add the change effect of touch, that is, when the finger touches the control, the background color of the control changes.
Use: android:background= "@ drawable/ your shadow xml file"
Attached: complete shadow xml code
At this point, the study on "how to set shadow effects in Android" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.