android shape 自定义形状 属性

1.ui情况

一个按钮,被一个圆环套着;一般,就是直接让人家切;可以不切呢;
这里写图片描述
其实,通用的方法;自己写shape
代码如下:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    android:shape="rectangle">
    <!--设置圆角渐变颜色-->
    <!--<gradient android:startColor="#FFFF0000"
    android:endColor="#80FF00FF"
    android:angle="270" />-->
    <!--设置内容离边界的距离-->
    <!-- <padding
         android:left="10dp"
         android:right="10dp"
         android:top="10dp"
     android:bottom="10dp" />-->
  <!--  &lt;!&ndash;设置填充颜色&ndash;&gt;
    <solid android:color="@color/white" />-->
    <!--设置描边颜色-->
      <stroke android:width="2.0dip"
      android:color="#e7e7e7"
      android:dashWidth="3.0dip"
      android:dashGap="0.0dip" />
    <!--设置圆角-->
    <corners
        android:bottomLeftRadius="26.5dp"
        android:bottomRightRadius="26.5dp"
        android:topLeftRadius="26.5dp"
        android:topRightRadius="26.5dp" />

</shape>

布局里写这个效果,代码如下:

  <ImageButton
                    android:id="@+id/imgbtn_collect"
                    android:layout_width="54dp"
                    android:layout_height="54dp"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="@dimen/base35dp"
                    android:background="@drawable/shape_4_circle26"
                    android:src="@mipmap/ic_river_collect" />

2.复习 阴影 填充 描边

solid:实心,就是填充的意思
android:color指定填充的颜色

gradient:渐变
android:startColor和android:endColor分别为起始和结束颜色,ndroid:angle是渐变角度,必须为45的整数倍。
另外渐变默认的模式为android:type=”linear”,即线性渐变,可以指定渐变为径向渐变,android:type=”radial”,径向渐变需要指定半径android:gradientRadius=”50”。

stroke:描边
android:width=”2dp” 描边的宽度,android:color 描边的颜色。
我们还可以把描边弄成虚线的形式,设置方式为:
android:dashWidth=”5dp”
android:dashGap=”3dp”
其中android:dashWidth表示’-‘这样一个横线的宽度,android:dashGap表示之间隔开的距离。

corners:圆角
android:radius为角的弧度,值越大角越圆。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不对法

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值