Shape can achieve some of the effects you want, for example, sometimes you get the focus on a button and press it to change the image to give the customer a better experience.
Shape can change some properties of these controls. It can be said that you can achieve focus in a small project, press the unified effect and style, and this is super convenient.
Create an XML file under your drawable folder, such as selector. xml
There are several attributes in shape, which are actually very simple:
<Shape>
<Solid Android: color = ""/> Solid property: What color
<Gradient
Android: startcolor = "" gradient property: 1. Start color
Android: endcolor = "2. End color
Android: angle = "90"/> 3. angle: the gradient angle must be a multiple of 45 degrees.
// The gradient is a linear gradient by default. Android: TYPE = "linear ",
// To change to a radial gradient Android: TYPE = "RADIAL", you must specify the radius Android: gradientradius = "30 ".
<Stroke attributes:
Android: width = "3dp" 1. stroke width
Android: dashwidth = "6dp" 2. Horizontal line width
Android: dashgap = "3dp" 3. Distance
Android: color = ""/> 4. Stroke color
<Corners rounded corner attributes:
Android: toprightradius = "20dp" upper right corner
Android: bottomleftradius = "20dp" bottom right corner
Android: topleftradius = "1dp" upper left corner
Android: bottomrightradius = "0dp" lower left corner
/>
<Padding
Android: Left = "10dp"
Android: Top = "10dp"
Android: Right = "10dp"
Android: Bottom = "10dp"/>
</Shape>
Normally in selector. XML, the focus is obtained. When you press it, you can set it to see different effects.
<Selector
<Item Android: state_pressed = "true">
<Shape>
</Shape>
</Item>
<Item Android: state_focused = "true">
<Shape>
</Shape>
</Item>
</Selector>
Okay, that's all. Try it if you want to see the effect ..