自定义rotate
android:toDegrees
值可以改变旋转的速度
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="1080">
<shape
android:shape="ring"
android:thickness="3px"
android:useLevel="false">
<gradient
android:centerColor="@color/colorbbbbbb"
android:centerY="0.50"
android:type="linear"
android:angle="-135"
android:endColor="@color/colorffffff"
android:centerX="0.5"
android:startColor="@color/colorbbbbbb"
android:useLevel="false" />
</shape>
</rotate>
shape图形类型
关于Shape的使用,简单来说说吧,
shape作为Android程序员你也是一定会用到的一个工具。
用官方的话来说,这是在 XML 中定义的一般形状。指向 GradientDrawable 的资源指针。
Shape可以绘制几种图形:
- 方型:rectangle,这也是默认的形状
- 原型:oval
- 线性:line
- 环:ring,为环的时候还有些针对它才使用的一些属性
我们用到的属性
solid :用于填充形状的纯色 corners:为形状产生圆角。仅当形状为矩形时适用
android:radius : 所有角都进行圆角处理半径,如果有单独设置某个角,这个属性则会被覆盖
android:topLeftRadius : 左上圆角 android:topRightRadius : 右上圆角
android:bottomLeftRadius : 左下圆角 android:bottomRightRadius : 右下圆角
padding : 要应用到包含视图元素的内边距(这会填充视图内容的位置如textview那么就是和文字都内编剧距离,而非形状)
android:left : 左内边距 android:top : 上内边距 android:right :右内边距
android:bottom :下内边距
size :
形状的大小,可以通过这里来设置形状大小,默认根据这里设置的大小来等比缩放至容器大小。在ImageView中可设置android:scaleType
设置为 “center” 来限制缩放。 stroke : 描边,就是最外面一层边线,可以是实线也可以是虚线
android:width :线宽 android:color :颜色 android:dashWidth :虚线的间距。仅在设置了
android:dashGap 时有效 android:dashGap : 虚线的厚度大小。仅在设置了 android:dashWidth 时有效
gradient :形状渐变颜色。
android:angle : 整型。渐变的角度(度)。0 为从左到右,90 为从下到上,270 从上到下。必须是 45 的倍数。默认值为 0
。
android:centerX : 浮点型。渐变中心的相对 X 轴位置 (0 - 1.0)。 android:centerY :
浮点型。渐变中心的相对 Y 轴位置 (0 - 1.0)。
android:centerColor :颜色。起始颜色与结束颜色之间的可选颜色
android:endColor : 颜色。结束颜色
android:gradientRadius : 浮点型。渐变的半径。仅在
android:type=“radial” 时适用。
android:startColor : 颜色。起始颜色
android:type :要应用的渐变图案的类型linear :线性渐变。这是默认值 radial : 径向渐变。起始颜色为中心颜色。 sweep : 流线型渐变。
android:useLevel [“true” | “false”] 如果要使用LevelListDrawable对象,就要设置为true。设置为true无渐变。false有渐变色默认为true
(要看效果还是建议设为false,属性还没摸透)