步骤一:创建gradient的XML文件 首先,我们需要创建一个XML文件来定义gradient。在项目的res目录下的drawable文件夹中创建一个新的XML文件,例如gradient_bg.xml,并在其中添加以下代码: <shapexmlns:android="android:shape="rectangle"><gradientandroid:type="linear"
<gradientandroid:startColor="#FF0000"android:endColor="#0000FF"android:type="linear"android:angle="0"/> </shape>| | 2 | 在布局文件中引用定义好的Gradient渐变 |xml <ImageView android:layout_width=“match_parent” android:layout_height=“match_parent” android:background=“@drawable/gradient”/...
中心点(centerX和centerY):设置渐变的中心点。这些值是相对于形状的宽度和高度的百分比。 <shapeandroid:shape="rectangle"><gradientandroid:type="radial"android:centerX="0.5"android:centerY="0.5"android:startColor="#f06"android:endColor="#ff0"/></shape> 半径(radius):设置径向渐变的半径。值是相对于...
1,gradient(渐变) 1<gradient>用以定义渐变色,可以定义两色渐变和三色渐变,及渐变样式; <?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <gradient android:type="linear" | "radial" | "sweep" //共有3中渐变类型,线性渐变(默认)/放射渐...
33<gradientandroid:type="radial"android:useLevel="false"android:gradientRadius="70" 34android:startColor="#ff0000"android:endColor="#0000ff"android:centerColor="#00ff00"/> 35</shape> 以下几幅图展示了上述三个渐变效果: 图6-1 线性渐变效果的椭圆 ...
<gradientandroid:type=["linear" | "radial" | "sweep"] //共有3中渐变类型,线性渐变(默认)/放射渐变/扫描式渐变android:angle="integer"//渐变角度,必须为45的倍数,0为从左到右,90为从上到下android:centerX="float"//渐变中心X的相当位置,范围为0~1android:centerY="float"//渐变中心Y的相当位置,...
android:left 左内间距 android:right 右内间距 android:top 上内间距 android:bottom 下内间距 gradient: 设置形状的渐变颜色,可以是线性渐变、辐射渐变、扫描性渐变 android:type 渐变的类型 linear 线性渐变,默认的渐变类型 radial 放射渐变,设置该项时,android:gradientRadius也必须设置 ...
渐变色半径.当 android:type="radial"时才使用。单独使用 android:type="radial"会报错。android:centerX 整型 渐变中心X点坐标的相对位置android:centerY 整型 渐变中心Y点坐标的相对位置--><gradientandroid:startColor="@android:color/white"android:centerColor="@android:color/black"android:endColor="@android...
Enumerates values returned by the LinearGradient, RadialGradient, and SweepGradient members and taken as a parameter of the F:Android.Graphics.Drawables.GradientDrawable.SetGradientType member.
一个具有渐变区域的Drawable,可以实现线性渐变,发散渐变和平铺渐变效果 核心节点:<gradient/>,有如下可选属性: startColor:渐变的起始颜色 centerColor:渐变的中间颜色 endColor:渐变的结束颜色 type:渐变类型,可选(linear,radial,sweep),线性渐变(可设置渐变角度),发散渐变(中间向四周发散),平铺渐变 ...