In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use Android to achieve Shape attribute gradient effect, the article is very detailed, has a certain reference value, interested friends must read it!
1, gradient
[1] To define gradient colors, you can define two-color gradient and three-color gradient, and gradient styles;
//LevelListDrawable is set to true when used. Set to false to have a gradient effect
There are three types of gradients: linear, radial, and sweep.
android: The useLevel attribute is not normally used. This property specifies whether the shape is to be used as a LevelListDrawable. The default value is false. The angle property does work only for linear gradients, and neither of the other two gradients has any movement. The centerX and centerY properties are used to set the center point of the gradient and are only valid when the gradient type is radial.
2, Demo effect
Let's use a three-color gradient to see how each of these three gradients looks: (If you don't use the centerColor attribute, it's a two-color gradient, which is optional) Note: When constructing a radial gradient, add the android:gradientRadius attribute (gradient radius), which means you must specify the gradient radius size to work
[1] Linear gradient
shape code
[2] Radioactive gradient
implementation code
[3] Sweep Gradient
implementation code
android:angle attribute modifies gradient angle (only valid for linear gradients)
1) android:angle="integer" //gradient angle, must be a multiple of 45, 0 is from left to right, 90 is from top to bottom
2) The angle property does only work with linear gradients, and the other two gradients do not have any movement.
Implementation code:
Android:CenterX and Android:CenterY
1) android:centerX="0.2",android:centerY="0.8"
2) CenterX and centerY attributes are used to set the center point position of the gradient, which is only valid when the gradient type is radial gradient.
3) The type is fractional or decimal, and Dimension is not accepted. The default value is 0.5, valid values are 0.0~1.0, beyond which the gradient effect is not visible. CenterX and CenterY are actually percentages of width and height.
Implementation code: Take the position of 20% width and 80% height as the new gradient origin
The above is "How to use Android to achieve Shape attribute gradient effect" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
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.